class TransactionArray

Ease of use class - Wraps an ordered array with some hash-like functions

Attributes

arr[RW]

Public Class Methods

new(arr=Array.new()) click to toggle source
# File lib/crdt/tgcounter.rb, line 191
def initialize(arr=Array.new())
  self.arr = arr
end

Public Instance Methods

==(other) click to toggle source
# File lib/crdt/tgcounter.rb, line 199
def ==(other)
  self.arr == other.arr
end
[](key) click to toggle source
# File lib/crdt/tgcounter.rb, line 208
def [](key)
  res = self.arr.select { |a| a[0] == key }
  res.first[1] if res && res.length > 0 &&res.first.length == 2
end
[]=(key, value) click to toggle source
# File lib/crdt/tgcounter.rb, line 203
def []=(key, value)
  self.delete(key) if self.[](key)
  self.arr << [key, value]
end
delete(key) click to toggle source
# File lib/crdt/tgcounter.rb, line 213
def delete(key)
  index = self.arr.index { |a| a[0] == key }
  self.arr.delete_at(index) if index
end
length() click to toggle source
# File lib/crdt/tgcounter.rb, line 195
def length()
  self.arr.length
end