Class: Immutable::Map::BlackFork

Inherits:
Fork show all
Defined in:
lib/immutable/map.rb

Overview

:nodoc:

Constant Summary

Constants inherited from Immutable::Map

Leaf

Instance Attribute Summary

Attributes inherited from Fork

#key, #left, #right, #value

Instance Method Summary collapse

Methods inherited from Fork

#[], #del, #each, #empty?, extract, #foldl_with_key, #foldr_with_key, #initialize

Methods inherited from Immutable::Map

#[], [], #delete, empty, #foldl, #foldr, #insert, #inspect, #map, #map_with_key, singleton

Constructor Details

This class inherits a constructor from Immutable::Map::Fork

Instance Method Details

#black?Boolean

Returns:

  • (Boolean)


362
363
364
# File 'lib/immutable/map.rb', line 362

def black?
  true
end

#ins(key, value) ⇒ Object



374
375
376
377
378
379
380
381
382
# File 'lib/immutable/map.rb', line 374

def ins(key, value)
  if key < self.key
    balance(left.ins(key, value), self.key, self.value, right)
  elsif key > self.key
    balance(left, self.key, self.value, right.ins(key, value))
  else
    BlackFork[left, key, value, right]
  end
end

#make_blackObject



370
371
372
# File 'lib/immutable/map.rb', line 370

def make_black
  self
end

#make_redObject



366
367
368
# File 'lib/immutable/map.rb', line 366

def make_red
  RedFork[left, key, value, right]
end

#red?Boolean

Returns:

  • (Boolean)


358
359
360
# File 'lib/immutable/map.rb', line 358

def red?
  false
end