Class: SparseArray
- Inherits:
-
Object
- Object
- SparseArray
- Defined in:
- lib/exonum/util/sparse_array.rb
Instance Method Summary collapse
Instance Method Details
#length ⇒ Object
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 |
#serialize ⇒ Object
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 |