Skip to content

Commit 0eb4390

Browse files
committed
📚 Update SequenceSet nomalized vs ordered rdoc
1 parent e4ef3eb commit 0eb4390

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

lib/net/imap/sequence_set.rb

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,20 @@ class IMAP
5656
# set = Net::IMAP::SequenceSet[1, 2, [3..7, 5], 6..10, 2048, 1024]
5757
# set.valid_string #=> "1:10,55,1024:2048"
5858
#
59-
# == Normalized form
59+
# == Ordered and Normalized sets
6060
#
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.
6765
#
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
7173
# preserve #string order while modifying a set, use #append, #string=, or
7274
# #replace.
7375
#
@@ -181,14 +183,15 @@ class IMAP
181183
# - #max: Returns the maximum number in the set.
182184
# - #minmax: Returns the minimum and maximum numbers in the set.
183185
#
184-
# <i>Accessing value by offset:</i>
186+
# <i>Accessing value by (normalized) offset:</i>
185187
# - #[] (aliased as #slice): Returns the number or consecutive subset at a
186188
# given offset or range of offsets.
187189
# - #at: Returns the number at a given offset.
188190
# - #find_index: Returns the given number's offset in the set
189191
#
190192
# <i>Set cardinality:</i>
191193
# - #count (aliased as #size): Returns the count of numbers in the set.
194+
# Duplicated numbers are not counted.
192195
# - #empty?: Returns whether the set has no members. \IMAP syntax does not
193196
# allow empty sequence sets.
194197
# - #valid?: Returns whether the set has any members.
@@ -838,8 +841,8 @@ def entries; each_entry.to_a end
838841
# <tt>*</tt> translates to an endless range. Use #limit to translate both
839842
# cases to a maximum value.
840843
#
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.
843846
#
844847
# Net::IMAP::SequenceSet["2,5:9,6,*,12:11"].elements
845848
# #=> [2, 5..9, 11..12, :*]
@@ -857,7 +860,7 @@ def elements; each_element.to_a end
857860
# translates to <tt>:*..</tt>. Use #limit to set <tt>*</tt> to a maximum
858861
# value.
859862
#
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
861864
# #string is not. <tt>*</tt> will sort last. See #normalize.
862865
#
863866
# Net::IMAP::SequenceSet["2,5:9,6,*,12:11"].ranges

0 commit comments

Comments
 (0)