Class: SortedSet

Inherits:
Object show all
Defined in:
lib/kyanite/set.rb

Overview

Set Classes and Additions

Kyanite definitions

Set, SortedSet, OrderedSet

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

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

#firstObject



151
152
153
# File 'lib/kyanite/set.rb', line 151

def first
  self[0]
end

#lastObject



156
157
158
# File 'lib/kyanite/set.rb', line 156

def last
  self[-1]
end

#to_sorted_setObject



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