Class: Kwyjibo::SparseVector

Inherits:
Object
  • Object
show all
Defined in:
lib/kwyjibo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h = {}) ⇒ SparseVector

Returns a new instance of SparseVector.



161
162
163
164
# File 'lib/kwyjibo.rb', line 161

def initialize(h = {})
    @vector = Hash.new(0)
    @vector = @vector.merge!(h)
end

Instance Attribute Details

#vectorObject (readonly)

Returns the value of attribute vector.



159
160
161
# File 'lib/kwyjibo.rb', line 159

def vector
  @vector
end

Instance Method Details

#[](i) ⇒ Object



166
167
168
# File 'lib/kwyjibo.rb', line 166

def [](i)
    @vector[i]
end