Class: Immutable::Map::BlackFork
- Inherits:
-
Fork
- Object
- Immutable::Map
- Fork
- Immutable::Map::BlackFork
- Defined in:
- lib/immutable/map.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Immutable::Map
Instance Attribute Summary
Attributes inherited from Fork
Instance Method Summary collapse
Methods inherited from Fork
#[], #del, #empty?, #foldl_with_key, #foldr_with_key, #initialize
Methods inherited from Immutable::Map
#[], [], #delete, #each, empty, #foldl, #foldr, #insert, #inspect, #map, #map_with_key, singleton
Methods included from Foldable
#foldl, #length, #product, #sum
Constructor Details
This class inherits a constructor from Immutable::Map::Fork
Instance Method Details
#black? ⇒ Boolean
360 361 362 |
# File 'lib/immutable/map.rb', line 360 def black? true end |
#ins(key, value) ⇒ Object
372 373 374 375 376 377 378 379 380 381 |
# File 'lib/immutable/map.rb', line 372 def ins(key, value) x = key <=> @key if x < 0 balance(@left.ins(key, value), @key, @value, @right) elsif x > 0 balance(@left, @key, @value, @right.ins(key, value)) else BlackFork[@left, key, value, @right] end end |
#make_black ⇒ Object
368 369 370 |
# File 'lib/immutable/map.rb', line 368 def make_black self end |
#make_red ⇒ Object
364 365 366 |
# File 'lib/immutable/map.rb', line 364 def make_red RedFork[left, key, value, right] end |
#red? ⇒ Boolean
356 357 358 |
# File 'lib/immutable/map.rb', line 356 def red? false end |