Sha256: edf1851ca4c1291d2e8735766681deda75eaaf2cca1bbedfea95a7347aef20ce

Contents?: true

Size: 215 Bytes

Versions: 6

Compression:

Stored size: 215 Bytes

Contents

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
exonum-client-ruby-0.1.0 lib/exonum/util/sparse_array.rb
exonum-client-ruby-0.0.5 lib/exonum/util/sparse_array.rb
exonum-client-ruby-0.0.4 lib/exonum/util/sparse_array.rb
exonum-client-ruby-0.0.3 lib/exonum/util/sparse_array.rb
exonum-client-ruby-0.0.2 lib/exonum/util/sparse_array.rb
exonum-client-ruby-0.0.1 lib/exonum/util/sparse_array.rb