Class: Immutable::Map::RedFork
- Inherits:
-
Fork
- Object
- Immutable::Map
- Fork
- Immutable::Map::RedFork
- 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
#[], #deconstruct, #del, #empty?, #foldl_with_key, #foldr_with_key, #initialize
Methods inherited from Immutable::Map
#==, [], #[], #delete, #each, empty, #eql?, #foldl, #foldr, #hash, #insert, #inspect, #map, #map_with_key, singleton, #to_h
Methods included from Foldable
#foldl, #length, #product, #sum
Constructor Details
This class inherits a constructor from Immutable::Map::Fork
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 |