@@ -56,18 +56,20 @@ class IMAP
56
56
# set = Net::IMAP::SequenceSet[1, 2, [3..7, 5], 6..10, 2048, 1024]
57
57
# set.valid_string #=> "1:10,55,1024:2048"
58
58
#
59
- # == Normalized form
59
+ # == Ordered and Normalized sets
60
60
#
61
- # When a sequence set is created with a single String value, that #string
62
- # representation is preserved. SequenceSet's internal representation
63
- # implicitly sorts all entries, de-duplicates numbers, and coalesces
64
- # adjacent or overlapping ranges. Most enumeration methods and offset-based
65
- # methods use this normalized representation. Most modification methods
66
- # will convert #string to its normalized form.
61
+ # Sometimes the order of the set's members is significant, such as with the
62
+ # +ESORT+, <tt>CONTEXT=SORT</tt>, and +UIDPLUS+ extensions. So, when a
63
+ # sequence set is created by the parser or with a single string value, that
64
+ # #string representation is preserved.
67
65
#
68
- # In some cases the order of the string representation is significant, such
69
- # as the +ESORT+, <tt>CONTEXT=SORT</tt>, and +UIDPLUS+ extensions. Use
70
- # #entries or #each_entry to enumerate the set in its original order. To
66
+ # Internally, SequenceSet stores a normalized representation which sorts all
67
+ # entries, de-duplicates numbers, and coalesces adjacent or overlapping
68
+ # ranges. Most methods use this normalized representation to achieve
69
+ # <tt>O(lg n)</tt> porformance. Use #entries or #each_entry to enumerate
70
+ # the set in its original order.
71
+ #
72
+ # Most modification methods convert #string to its normalized form. To
71
73
# preserve #string order while modifying a set, use #append, #string=, or
72
74
# #replace.
73
75
#
@@ -181,14 +183,15 @@ class IMAP
181
183
# - #max: Returns the maximum number in the set.
182
184
# - #minmax: Returns the minimum and maximum numbers in the set.
183
185
#
184
- # <i>Accessing value by offset:</i>
186
+ # <i>Accessing value by (normalized) offset:</i>
185
187
# - #[] (aliased as #slice): Returns the number or consecutive subset at a
186
188
# given offset or range of offsets.
187
189
# - #at: Returns the number at a given offset.
188
190
# - #find_index: Returns the given number's offset in the set
189
191
#
190
192
# <i>Set cardinality:</i>
191
193
# - #count (aliased as #size): Returns the count of numbers in the set.
194
+ # Duplicated numbers are not counted.
192
195
# - #empty?: Returns whether the set has no members. \IMAP syntax does not
193
196
# allow empty sequence sets.
194
197
# - #valid?: Returns whether the set has any members.
@@ -838,8 +841,8 @@ def entries; each_entry.to_a end
838
841
# <tt>*</tt> translates to an endless range. Use #limit to translate both
839
842
# cases to a maximum value.
840
843
#
841
- # If the original input was unordered or contains overlapping ranges, the
842
- # returned ranges will be ordered and coalesced .
844
+ # The returned elements will be sorted and coalesced, even when the input
845
+ # #string is not. <tt>*</tt> will sort last. See #normalize .
843
846
#
844
847
# Net::IMAP::SequenceSet["2,5:9,6,*,12:11"].elements
845
848
# #=> [2, 5..9, 11..12, :*]
@@ -857,7 +860,7 @@ def elements; each_element.to_a end
857
860
# translates to <tt>:*..</tt>. Use #limit to set <tt>*</tt> to a maximum
858
861
# value.
859
862
#
860
- # The returned ranges will be ordered and coalesced, even when the input
863
+ # The returned ranges will be sorted and coalesced, even when the input
861
864
# #string is not. <tt>*</tt> will sort last. See #normalize.
862
865
#
863
866
# Net::IMAP::SequenceSet["2,5:9,6,*,12:11"].ranges
0 commit comments