@@ -183,11 +183,11 @@ class IMAP
183
183
# - #max: Returns the maximum number in the set.
184
184
# - #minmax: Returns the minimum and maximum numbers in the set.
185
185
#
186
- # <i>Accessing value by (normalized) offset:</i>
186
+ # <i>Accessing value by offset in sorted set :</i>
187
187
# - #[] (aliased as #slice): Returns the number or consecutive subset at a
188
- # given offset or range of offsets.
189
- # - #at: Returns the number at a given offset.
190
- # - #find_index: Returns the given number's offset in the set
188
+ # given offset or range of offsets in the sorted set .
189
+ # - #at: Returns the number at a given offset in the sorted set .
190
+ # - #find_index: Returns the given number's offset in the sorted set.
191
191
#
192
192
# <i>Set cardinality:</i>
193
193
# - #count (aliased as #size): Returns the count of numbers in the set.
@@ -1083,10 +1083,10 @@ def has_duplicates?
1083
1083
count_with_duplicates != count
1084
1084
end
1085
1085
1086
- # Returns the index of +number+ in the set, or +nil+ if +number+ isn't in
1087
- # the set.
1086
+ # Returns the (sorted and deduplicated) index of +number+ in the set, or
1087
+ # +nil+ if +number+ isn't in the set.
1088
1088
#
1089
- # Related: #[]
1089
+ # Related: #[], #at
1090
1090
def find_index ( number )
1091
1091
number = to_tuple_int number
1092
1092
each_tuple_with_index do |min , max , idx_min |
@@ -1120,8 +1120,11 @@ def reverse_each_tuple_with_index
1120
1120
1121
1121
# :call-seq: at(index) -> integer or nil
1122
1122
#
1123
- # Returns a number from +self+, without modifying the set. Behaves the
1124
- # same as #[], except that #at only allows a single integer argument.
1123
+ # Returns the number at the given +index+ in the sorted set, without
1124
+ # modifying the set.
1125
+ #
1126
+ # +index+ is interpreted the same as in #[], except that #at only allows a
1127
+ # single integer argument.
1125
1128
#
1126
1129
# Related: #[], #slice
1127
1130
def at ( index )
@@ -1146,17 +1149,18 @@ def at(index)
1146
1149
# seqset[range] -> sequence set or nil
1147
1150
# slice(range) -> sequence set or nil
1148
1151
#
1149
- # Returns a number or a subset from +self+, without modifying the set.
1152
+ # Returns a number or a subset from the _sorted_ set, without modifying
1153
+ # the set.
1150
1154
#
1151
1155
# When an Integer argument +index+ is given, the number at offset +index+
1152
- # is returned:
1156
+ # in the sorted set is returned:
1153
1157
#
1154
1158
# set = Net::IMAP::SequenceSet["10:15,20:23,26"]
1155
1159
# set[0] #=> 10
1156
1160
# set[5] #=> 15
1157
1161
# set[10] #=> 26
1158
1162
#
1159
- # If +index+ is negative, it counts relative to the end of +self+ :
1163
+ # If +index+ is negative, it counts relative to the end of the sorted set :
1160
1164
# set = Net::IMAP::SequenceSet["10:15,20:23,26"]
1161
1165
# set[-1] #=> 26
1162
1166
# set[-3] #=> 22
@@ -1168,13 +1172,14 @@ def at(index)
1168
1172
# set[11] #=> nil
1169
1173
# set[-12] #=> nil
1170
1174
#
1171
- # The result is based on the normalized set— sorted and de-duplicated— not
1172
- # on the assigned value of #string.
1175
+ # The result is based on the sorted and de-duplicated set, not on the
1176
+ # ordered #entries in #string.
1173
1177
#
1174
1178
# set = Net::IMAP::SequenceSet["12,20:23,11:16,21"]
1175
1179
# set[0] #=> 11
1176
1180
# set[-1] #=> 23
1177
1181
#
1182
+ # Related: #at
1178
1183
def []( index , length = nil )
1179
1184
if length then slice_length ( index , length )
1180
1185
elsif index . is_a? ( Range ) then slice_range ( index )
0 commit comments