Class: FlatKit::SentinelInternalNode

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/flat_kit/sentinel_internal_node.rb

Overview

Private: The Sentinel Internal Node is a private class used by the MergeTree class.

This class represents an empty / completed node in the merge tree where all the data from the descendant leaf node is full used up.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left: nil, right: nil) ⇒ SentinelInternalNode

Returns a new instance of SentinelInternalNode.



16
17
18
19
20
21
# File 'lib/flat_kit/sentinel_internal_node.rb', line 16

def initialize(left: nil, right: nil)
  @left = nil
  @right = nil
  @winner = nil
  @next_level = nil
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



11
12
13
# File 'lib/flat_kit/sentinel_internal_node.rb', line 11

def left
  @left
end

#next_levelObject

Returns the value of attribute next_level.



14
15
16
# File 'lib/flat_kit/sentinel_internal_node.rb', line 14

def next_level
  @next_level
end

#rightObject (readonly)

Returns the value of attribute right.



12
13
14
# File 'lib/flat_kit/sentinel_internal_node.rb', line 12

def right
  @right
end

#winnerObject (readonly)

Returns the value of attribute winner.



13
14
15
# File 'lib/flat_kit/sentinel_internal_node.rb', line 13

def winner
  @winner
end

Instance Method Details

#<=>(other) ⇒ Object

A sentinal node is always greater than any other node



32
33
34
35
# File 'lib/flat_kit/sentinel_internal_node.rb', line 32

def <=>(other)
  return 0 if other.sentinel?
  return 1
end

#leaf?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/flat_kit/sentinel_internal_node.rb', line 27

def leaf?
  true
end

#sentinel?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/flat_kit/sentinel_internal_node.rb', line 23

def sentinel?
  true
end