Class: SortedSet
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
          ::Set
         | |
| Instance Chain: 
          self,
          ::Set,
          ::Enumerable
         | |
| Inherits: | Set 
 | 
| Defined in: | lib/set.rb | 
Overview
SortedSet implements a ::Set that guarantees that its elements are yielded in sorted order (according to the return values of their #<=> methods) when iterating over them.
All elements that are added to a SortedSet must respond to the <=> method for comparison.
Also, all elements must be mutually comparable: el1 <=> el2 must not return nil for any elements el1 and el2, else an ArgumentError will be raised when iterating over the SortedSet.
Example
require "set"
set = SortedSet.new([2, 1, 5, 6, 4, 5, 3, 3, 3])
ary = []
set.each do |obj|
  ary << obj
end
p ary # => [1, 2, 3, 4, 5, 6]
set2 = SortedSet.new([1, 2, "3"])
set2.each { |obj| } # => raises ArgumentError: comparison of Fixnum with String failedClass Method Summary
::Set - Inherited
Instance Attribute Summary
Instance Method Summary
::Set - Inherited
| #& | Returns a new set containing elements common to the set and the given enumerable object. | 
| #+ | Alias for Set#|. | 
| #- | Returns a new set built by duplicating the set, removing every element that appears in the given enumerable object. | 
| #< | Alias for Set#proper_subset?. | 
| #<< | Alias for Set#add. | 
| #<= | Alias for Set#subset?. | 
| #== | Returns true if two sets are equal. | 
| #> | Alias for Set#proper_superset?. | 
| #>= | Alias for Set#superset?. | 
| #^ | Returns a new set containing elements exclusive between the set and the given enumerable object. | 
| #add | Adds the given object to the set and returns self. | 
| #add? | Adds the given object to the set and returns self. | 
| #classify | Classifies the set by the return value of the given block and returns a hash of  | 
| #clear | Removes all elements and returns self. | 
| #collect! | Replaces the elements with ones returned by collect(). | 
| #delete | Deletes the given object from the set and returns self. | 
| #delete? | Deletes the given object from the set and returns self. | 
| #delete_if | Deletes every element of the set for which block evaluates to true, and returns self. | 
| #difference | Alias for Set#-. | 
| #disjoint? | Returns true if the set and the given set have no element in common. | 
| #divide | Divides the set into a set of subsets according to the commonality defined by the given block. | 
| #each | Calls the given block once for each element in the set, passing the element as parameter. | 
| #flatten | Returns a new set that is a copy of the set, flattening each containing set recursively. | 
| #flatten! | Equivalent to Set#flatten, but replaces the receiver with the result in place. | 
| #include? | Returns true if the set contains the given object. | 
| #initialize_clone | Clone internal hash. | 
| #initialize_dup | Dup internal hash. | 
| #inspect | Returns a string containing a human-readable representation of the set. | 
| #intersect? | Returns true if the set and the given set have at least one element in common. | 
| #intersection | Alias for Set#&. | 
| #keep_if | Deletes every element of the set for which block evaluates to false, and returns self. | 
| #length | Alias for Set#size. | 
| #map! | Alias for Set#collect!. | 
| #member? | Alias for Set#include?. | 
| #merge | Merges the elements of the given enumerable object to the set and returns self. | 
| #proper_subset? | Returns true if the set is a proper subset of the given set. | 
| #proper_superset? | Returns true if the set is a proper superset of the given set. | 
| #reject! | Equivalent to Set#delete_if, but returns nil if no changes were made. | 
| #replace | Replaces the contents of the set with the contents of the given enumerable object and returns self. | 
| #select! | Equivalent to Set#keep_if, but returns nil if no changes were made. | 
| #size | Returns the number of elements. | 
| #subset? | Returns true if the set is a subset of the given set. | 
| #subtract | Deletes every element that appears in the given enumerable object and returns self. | 
| #superset? | Returns true if the set is a superset of the given set. | 
| #to_a | Converts the set to an array. | 
| #to_set | Returns self if no arguments are given. | 
| #union | Alias for Set#|. | 
| #| | Returns a new set built by merging the set and the elements of the given enumerable object. | 
::Enumerable - Included
| #to_set | Makes a set from the enumerable object with given arguments. | 
Constructor Details
This class inherits a constructor from Set