Class: SortedSet
Overview
Set Classes and Additions
- Kyanite definitions
- Kyanite tests and examples
-
TestKyaniteSet
- Usage
-
require ‘kyanite/set’
Differences between the set classes
Set-
is unordered. Examples: test_set
- 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
-
#[](index) ⇒ Object
n-th Element.
-
#first ⇒ Object
First element.
-
#last ⇒ Object
Last element.
-
#to_sorted_set ⇒ Object
Self.
-
#unshift(e) ⇒ Object
das war mal auskommentiert, wird aber von nat_lang gebraucht.
Instance Method Details
#[](index) ⇒ Object
n-th Element. inefficient!!
146 147 148 |
# File 'lib/kyanite/set.rb', line 146 def [](index) self.to_a[index] end |
#first ⇒ Object
151 152 153 |
# File 'lib/kyanite/set.rb', line 151 def first self[0] end |
#last ⇒ Object
156 157 158 |
# File 'lib/kyanite/set.rb', line 156 def last self[-1] end |
#to_sorted_set ⇒ Object
167 168 169 |
# File 'lib/kyanite/set.rb', line 167 def to_sorted_set self end |
#unshift(e) ⇒ Object
das war mal auskommentiert, wird aber von nat_lang gebraucht
162 163 164 |
# File 'lib/kyanite/set.rb', line 162 def unshift(e) self << e end |