Class: SortedSet

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

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

- (Object) [](index)

n-th Element. inefficient!!

Returns:

  • n-th Element



146
147
148
# File 'lib/kyanite/set.rb', line 146

def [](index)
  self.to_a[index]
end

- (Object) first

First element

Returns:

  • first element



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

def first
  self[0]
end

- (Object) last

Last element

Returns:

  • last element



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

def last
  self[-1]
end

- (Object) to_sorted_set

Self

Returns:

  • self



167
168
169
# File 'lib/kyanite/set.rb', line 167

def to_sorted_set
  self
end