Class: Immutable::Map::RedFork
- Inherits:
-
Fork
- Object
- Map
- Fork
- Immutable::Map::RedFork
show all
- Defined in:
- lib/immutable/map.rb
Overview
Instance Attribute Summary
Attributes inherited from Fork
#key, #left, #right, #value
Instance Method Summary
collapse
Methods inherited from Fork
#[], #deconstruct, #del, #empty?, #foldl_with_key, #foldr_with_key, #initialize
Instance Method Details
#black? ⇒ Boolean
345
346
347
|
# File 'lib/immutable/map.rb', line 345
def black?
false
end
|
#ins(key, value) ⇒ Object
357
358
359
360
361
362
363
364
365
366
|
# File 'lib/immutable/map.rb', line 357
def ins(key, value)
x = key <=> @key
if x < 0
RedFork[@left.ins(key, value), @key, @value, @right]
elsif x > 0
RedFork[@left, @key, @value, @right.ins(key, value)]
else
RedFork[@left, key, value, @right]
end
end
|
#make_black ⇒ Object
353
354
355
|
# File 'lib/immutable/map.rb', line 353
def make_black
BlackFork[left, key, value, right]
end
|
#make_red ⇒ Object
349
350
351
|
# File 'lib/immutable/map.rb', line 349
def make_red
self
end
|
#red? ⇒ Boolean
341
342
343
|
# File 'lib/immutable/map.rb', line 341
def red?
true
end
|