Class: MSSMT::Store::DefaultStore
- Inherits:
-
Object
- Object
- MSSMT::Store::DefaultStore
- Defined in:
- lib/mssmt/store/default_store.rb
Overview
In-memory implementation of the tree store.
Instance Attribute Summary collapse
-
#branches ⇒ Object
Returns the value of attribute branches.
-
#leaves ⇒ Object
Returns the value of attribute leaves.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
-
#delete_branch(node_hash) ⇒ Object
Delete branch node.
-
#delete_leaf(node_hash) ⇒ Object
Delete leaf node.
-
#initialize ⇒ DefaultStore
constructor
A new instance of DefaultStore.
-
#insert_branch(branch) ⇒ Object
Insert branch node.
-
#insert_leaf(leaf) ⇒ Object
Insert leaf node.
Constructor Details
#initialize ⇒ DefaultStore
Returns a new instance of DefaultStore.
9 10 11 12 13 |
# File 'lib/mssmt/store/default_store.rb', line 9 def initialize @branches = {} @leaves = {} @root = nil end |
Instance Attribute Details
#branches ⇒ Object
Returns the value of attribute branches.
7 8 9 |
# File 'lib/mssmt/store/default_store.rb', line 7 def branches @branches end |
#leaves ⇒ Object
Returns the value of attribute leaves.
7 8 9 |
# File 'lib/mssmt/store/default_store.rb', line 7 def leaves @leaves end |
#root ⇒ Object
Returns the value of attribute root.
7 8 9 |
# File 'lib/mssmt/store/default_store.rb', line 7 def root @root end |
Instance Method Details
#delete_branch(node_hash) ⇒ Object
Delete branch node.
37 38 39 |
# File 'lib/mssmt/store/default_store.rb', line 37 def delete_branch(node_hash) branches.delete(node_hash) end |
#delete_leaf(node_hash) ⇒ Object
Delete leaf node
43 44 45 |
# File 'lib/mssmt/store/default_store.rb', line 43 def delete_leaf(node_hash) leaves.delete(node_hash) end |
#insert_branch(branch) ⇒ Object
Insert branch node.
18 19 20 21 22 23 24 |
# File 'lib/mssmt/store/default_store.rb', line 18 def insert_branch(branch) unless branch.is_a?(MSSMT::BranchNode) raise "branch must be MSSMT::BranchNode" end branches[branch.node_hash] = branch end |
#insert_leaf(leaf) ⇒ Object
Insert leaf node.
29 30 31 32 33 |
# File 'lib/mssmt/store/default_store.rb', line 29 def insert_leaf(leaf) raise "leaf must be MSSMT::LeafNode" unless leaf.is_a?(MSSMT::LeafNode) leaves[leaf.node_hash] = leaf end |