Class: SortedSet
- Defined in
- lib/kyanite/set.rb
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)
-
- (Object) [](index)
n-th Element.
-
- (Object) first
First element.
-
- (Object) last
Last element.
-
- (Object) to_sorted_set
Self.
Instance Method Details
- (Object) [](index)
n-th Element. inefficient!!
146 147 148 |
# File 'lib/kyanite/set.rb', line 146 def [](index) self.to_a[index] end |
- (Object) first
First element
151 152 153 |
# File 'lib/kyanite/set.rb', line 151 def first self[0] end |
- (Object) last
Last element
156 157 158 |
# File 'lib/kyanite/set.rb', line 156 def last self[-1] end |
- (Object) to_sorted_set
Self
167 168 169 |
# File 'lib/kyanite/set.rb', line 167 def to_sorted_set self end |