Class: Kwyjibo::SparseVector
- Inherits:
-
Object
- Object
- Kwyjibo::SparseVector
- Defined in:
- lib/kwyjibo.rb
Instance Attribute Summary collapse
-
#vector ⇒ Object
readonly
Returns the value of attribute vector.
Instance Method Summary collapse
- #[](i) ⇒ Object
-
#initialize(h = {}) ⇒ SparseVector
constructor
A new instance of SparseVector.
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
#vector ⇒ Object (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 |