Class: SparseArray

Inherits:
Object
  • Object
show all
Defined in:
lib/exonum/util/sparse_array.rb

Instance Method Summary collapse

Instance Method Details

#lengthObject



2
3
4
5
6
7
8
# File 'lib/exonum/util/sparse_array.rb', line 2

def length
  if keys.any?
    keys.max + 1
  else
    0
  end
end

#serializeObject



10
11
12
13
14
15
16
# File 'lib/exonum/util/sparse_array.rb', line 10

def serialize
  if keys.any?
    (0..(length-1)).map {|i| fetch i, 0 }
  else
    []
  end
end