Class: Set
- Defined in
 - lib/kyanite/set.rb
 
- Subclasses
 - OrderedSet
 
Set Classes and Additions
- Kyanite definitions
 - Kyanite tests and examples
 - Usage
 - 
require 'kyanite/set'
 
Differences between the set classes
- OrderedSet
 - 
is ordered, it retains the original order, but it will not continually re-sorted -- as long you don't use Dictionary#order_by. Examples: test_ordered_set
 - SortedSet
 - 
is ordered and sorted. It is always in order. Examples: test_sorted_set
 
Instance Method Summary (collapse)
- 
  
    
      - (Integer) <=>(other) 
    
    
  
  
    
Comparison operator (by size).
 - 
  
    
      - (Object) first 
    
    
  
  
    
Any element.
 - 
  
    
      - (Object) last 
    
    
  
  
    
Any other element.
 - 
  
    
      - (Object) push(elt) 
    
    
  
  
    
Adds the element to the set.
 
Instance Method Details
- (Integer) <=>(other)
Comparison operator (by size)
      34 35 36  | 
    
      # File 'lib/kyanite/set.rb', line 34 def <=>(other) self.size <=> other.size end  | 
  
- (Object) first
Any element
      44 45 46 47 48  | 
    
      # File 'lib/kyanite/set.rb', line 44 def first @hash.each do |key, value| return key end end  | 
  
- (Object) last
Any other element
      52 53 54 55 56 57 58 59 60 61 62  | 
    
      # File 'lib/kyanite/set.rb', line 52 def last first = nil @hash.each do |key, value| if first.nil? first = key next else return key end #if end #do end  | 
  
- (Object) push(elt)
Adds the element to the set.
      27 28 29  | 
    
      # File 'lib/kyanite/set.rb', line 27 def push(elt) self << elt end  |