Class: RangeList::AvlTree::RBTreeAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- RangeList::AvlTree::RBTreeAdapter
- Defined in:
- lib/range_list/avl_tree/rbtree_adapter.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize ⇒ RBTreeAdapter
constructor
A new instance of RBTreeAdapter.
- #lower_entry(key) ⇒ Object
- #put(key, value) ⇒ Object
- #remove(key) ⇒ Object
- #sub_map(from_key, to_key) ⇒ Object
Constructor Details
#initialize ⇒ RBTreeAdapter
Returns a new instance of RBTreeAdapter.
10 11 12 |
# File 'lib/range_list/avl_tree/rbtree_adapter.rb', line 10 def initialize @rbtree = RBTree.new end |
Instance Method Details
#each(&block) ⇒ Object
30 31 32 |
# File 'lib/range_list/avl_tree/rbtree_adapter.rb', line 30 def each(&block) rbtree.each(&block) end |
#lower_entry(key) ⇒ Object
18 19 20 |
# File 'lib/range_list/avl_tree/rbtree_adapter.rb', line 18 def lower_entry(key) rbtree.upper_bound(key) end |
#put(key, value) ⇒ Object
14 15 16 |
# File 'lib/range_list/avl_tree/rbtree_adapter.rb', line 14 def put(key, value) rbtree[key] = value end |
#remove(key) ⇒ Object
26 27 28 |
# File 'lib/range_list/avl_tree/rbtree_adapter.rb', line 26 def remove(key) rbtree.delete(key) end |
#sub_map(from_key, to_key) ⇒ Object
22 23 24 |
# File 'lib/range_list/avl_tree/rbtree_adapter.rb', line 22 def sub_map(from_key, to_key) rbtree.bound(from_key, to_key).to_a end |