Class: IntervalSkipList::Node

### Home Classes Methods

### In Files

- lib/treetop/runtime/interval_skip_list/node.rb

### Parent

IntervalSkipList::HeadNode

### Methods

- ::new
- #all_forward_markers
- #can_be_promoted_higher?
- #delete
- #delete_marker_from_path
- #demote_inbound_markers
- #demote_markers
- #demote_outbound_markers
- #forward_node_with_marker_at_or_above_level?
- #place_marker_on_inbound_path
- #place_marker_on_outbound_path
- #promote_markers
- #propagate_length_change
- #update_forward_pointers

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Treetop
- Treetop::Compiler
- Treetop::Compiler::AndPredicate
- Treetop::Compiler::AnythingSymbol
- Treetop::Compiler::AtomicExpression
- Treetop::Compiler::CharacterClass
- Treetop::Compiler::Choice
- Treetop::Compiler::DeclarationSequence
- Treetop::Compiler::Grammar
- Treetop::Compiler::GrammarCompiler
- Treetop::Compiler::InlineModule
- Treetop::Compiler::InlineModuleMixin
- Treetop::Compiler::LexicalAddressSpace
- Treetop::Compiler::Metagrammar
- Treetop::Compiler::Metagrammar::BracketExpression0
- Treetop::Compiler::Metagrammar::CharacterClass0
- Treetop::Compiler::Metagrammar::CharacterClass1
- Treetop::Compiler::Metagrammar::CharacterClass2
- Treetop::Compiler::Metagrammar::CharacterClass3
- Treetop::Compiler::Metagrammar::CharacterClass4
- Treetop::Compiler::Metagrammar::Choice0
- Treetop::Compiler::Metagrammar::Choice1
- Treetop::Compiler::Metagrammar::Choice2
- Treetop::Compiler::Metagrammar::CommentToEol0
- Treetop::Compiler::Metagrammar::CommentToEol1
- Treetop::Compiler::Metagrammar::DeclarationSequence0
- Treetop::Compiler::Metagrammar::DeclarationSequence1
- Treetop::Compiler::Metagrammar::DeclarationSequence2
- Treetop::Compiler::Metagrammar::DeclarationSequence3
- Treetop::Compiler::Metagrammar::DoubleQuotedString0
- Treetop::Compiler::Metagrammar::DoubleQuotedString1
- Treetop::Compiler::Metagrammar::Grammar0
- Treetop::Compiler::Metagrammar::Grammar1
- Treetop::Compiler::Metagrammar::GrammarName0
- Treetop::Compiler::Metagrammar::IncludeDeclaration0
- Treetop::Compiler::Metagrammar::IncludeDeclaration1
- Treetop::Compiler::Metagrammar::InlineModule0
- Treetop::Compiler::Metagrammar::InlineModule1
- Treetop::Compiler::Metagrammar::KeywordInsideGrammar0
- Treetop::Compiler::Metagrammar::LabeledExpressionSequenceBody0
- Treetop::Compiler::Metagrammar::LabeledSequencePrimary0
- Treetop::Compiler::Metagrammar::LabeledSequencePrimary1
- Treetop::Compiler::Metagrammar::ModuleDeclaration0
- Treetop::Compiler::Metagrammar::ModuleDeclaration1
- Treetop::Compiler::Metagrammar::ModuleDeclaration2
- Treetop::Compiler::Metagrammar::ModuleDeclaration3
- Treetop::Compiler::Metagrammar::ModuleDeclaration4
- Treetop::Compiler::Metagrammar::ModuleDeclaration5
- Treetop::Compiler::Metagrammar::NamedLabel0
- Treetop::Compiler::Metagrammar::NamedLabel1
- Treetop::Compiler::Metagrammar::NamedLabel2
- Treetop::Compiler::Metagrammar::NodeClassDeclarations0
- Treetop::Compiler::Metagrammar::NodeClassDeclarations1
- Treetop::Compiler::Metagrammar::NodeClassExpression0
- Treetop::Compiler::Metagrammar::NodeClassExpression1
- Treetop::Compiler::Metagrammar::NodeClassExpression2
- Treetop::Compiler::Metagrammar::NodeClassExpression3
- Treetop::Compiler::Metagrammar::NonSpaceChar0
- Treetop::Compiler::Metagrammar::Nonterminal0
- Treetop::Compiler::Metagrammar::Nonterminal1
- Treetop::Compiler::Metagrammar::NullLabel0
- Treetop::Compiler::Metagrammar::OccurrenceRange0
- Treetop::Compiler::Metagrammar::ParenthesizedExpression0
- Treetop::Compiler::Metagrammar::ParenthesizedExpression1
- Treetop::Compiler::Metagrammar::ParsingRule0
- Treetop::Compiler::Metagrammar::ParsingRule1
- Treetop::Compiler::Metagrammar::PredicateBlock0
- Treetop::Compiler::Metagrammar::Primary0
- Treetop::Compiler::Metagrammar::Primary1
- Treetop::Compiler::Metagrammar::Primary2
- Treetop::Compiler::Metagrammar::Primary3
- Treetop::Compiler::Metagrammar::Primary4
- Treetop::Compiler::Metagrammar::Primary5
- Treetop::Compiler::Metagrammar::Primary6
- Treetop::Compiler::Metagrammar::Primary7
- Treetop::Compiler::Metagrammar::QuotedString0
- Treetop::Compiler::Metagrammar::RequireStatement0
- Treetop::Compiler::Metagrammar::Sequence0
- Treetop::Compiler::Metagrammar::Sequence1
- Treetop::Compiler::Metagrammar::SequencePrimary0
- Treetop::Compiler::Metagrammar::SequencePrimary1
- Treetop::Compiler::Metagrammar::SequencePrimary2
- Treetop::Compiler::Metagrammar::SequencePrimary3
- Treetop::Compiler::Metagrammar::SequencePrimary4
- Treetop::Compiler::Metagrammar::SequencePrimary5
- Treetop::Compiler::Metagrammar::SingleQuotedString0
- Treetop::Compiler::Metagrammar::SingleQuotedString1
- Treetop::Compiler::Metagrammar::TrailingInlineModule0
- Treetop::Compiler::Metagrammar::TrailingInlineModule1
- Treetop::Compiler::Metagrammar::TrailingInlineModule2
- Treetop::Compiler::Metagrammar::TreetopFile0
- Treetop::Compiler::Metagrammar::TreetopFile1
- Treetop::Compiler::Metagrammar::TreetopFile2
- Treetop::Compiler::Metagrammar::UnlabeledSequencePrimary0
- Treetop::Compiler::Metagrammar::UnlabeledSequencePrimary1
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody0
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody1
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody2
- Treetop::Compiler::MetagrammarParser
- Treetop::Compiler::Nonterminal
- Treetop::Compiler::NotPredicate
- Treetop::Compiler::OccurrenceRange
- Treetop::Compiler::OneOrMore
- Treetop::Compiler::Optional
- Treetop::Compiler::ParenthesizedExpression
- Treetop::Compiler::ParsingExpression
- Treetop::Compiler::ParsingRule
- Treetop::Compiler::Predicate
- Treetop::Compiler::PredicateBlock
- Treetop::Compiler::Repetition
- Treetop::Compiler::RubyBuilder
- Treetop::Compiler::Sequence
- Treetop::Compiler::SequenceElementAccessorModule
- Treetop::Compiler::Terminal
- Treetop::Compiler::TransientPrefix
- Treetop::Compiler::TreetopFile
- Treetop::Compiler::ZeroOrMore
- Treetop::Polyglot
- Treetop::Runtime
- Treetop::Runtime::CompiledParser
- Treetop::Runtime::SyntaxNode
- Treetop::Runtime::TerminalParseFailure
- Treetop::Runtime::TerminalSyntaxNode
- IntervalSkipList
- IntervalSkipList::HeadNode
- IntervalSkipList::Node
- Object
- String

No matching classes.

# IntervalSkipList::Node

### Attributes

endpoint_of[R]
key[RW]
markers[R]

### Public Class Methods

new(key, height, path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 6
    def initialize(key, height, path)
      super(height)
      @key = key
      @markers = []
      @endpoint_of = []
      update_forward_pointers(path)
      promote_markers(path)
    end

### Public Instance Methods

all_forward_markers() click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 15
    def all_forward_markers
      markers.flatten
    end

delete(path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 19
    def delete(path)
      0.upto(top_level) do |i|
        path[i].forward[i] = forward[i]
      end
      demote_markers(path)
    end

propagate_length_change(length_change) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 26
    def propagate_length_change(length_change)
      cur_node = self
      while cur_node do
        cur_node.key += length_change
        cur_node = cur_node.forward[0]
      end
    end

### Protected Instance Methods

can_be_promoted_higher?(marker, level) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 74
    def can_be_promoted_higher?(marker, level)
      level < top_level && forward[level + 1] && forward[level + 1].markers.include?(marker)
    end

delete_marker_from_path(marker, level, terminus) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 78
    def delete_marker_from_path(marker, level, terminus)
      cur_node = self
      until cur_node == terminus
        cur_node.forward_markers[level].delete(marker)
        cur_node.markers.delete(marker)
        cur_node = cur_node.forward[level]
      end
    end

demote_inbound_markers(path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 92
    def demote_inbound_markers(path)
      demoted = []
      new_demoted = []

      top_level.downto(0) do |i|
        incoming_markers = path[i].forward_markers[i].dup
        incoming_markers.each do |marker|
          unless forward_node_with_marker_at_or_above_level?(marker, i)
            path[i].forward_markers[i].delete(marker)
            new_demoted.push(marker)
          end
        end

        demoted.each do |marker|
          path[i + 1].place_marker_on_inbound_path(marker, i, path[i])

          if forward[i].markers.include?(marker)
            path[i].forward_markers[i].push(marker)
          else
            new_demoted.push(marker)
          end
        end

        demoted = new_demoted
        new_demoted = []
      end
    end

demote_markers(path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 87
    def demote_markers(path)
      demote_inbound_markers(path)
      demote_outbound_markers(path)
    end

demote_outbound_markers(path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 120
    def demote_outbound_markers(path)
      demoted = []
      new_demoted = []

      top_level.downto(0) do |i|
        forward_markers[i].each do |marker|
          new_demoted.push(marker) unless path[i].forward_markers[i].include?(marker)
        end

        demoted.each do |marker|
          forward[i].place_marker_on_outbound_path(marker, i, forward[i + 1])
          new_demoted.push(marker) unless path[i].forward_markers[i].include?(marker)
        end

        demoted = new_demoted
        new_demoted = []
      end
    end

forward_node_with_marker_at_or_above_level?(marker, level) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 139
    def forward_node_with_marker_at_or_above_level?(marker, level)
      level.upto(top_level) do |i|
        return true if forward[i].markers.include?(marker)
      end
      false
    end

place_marker_on_inbound_path(marker, level, terminus) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 155
    def place_marker_on_inbound_path(marker, level, terminus)
      cur_node = self
      until cur_node == terminus
        cur_node.forward_markers[level].push(marker)
        cur_node = cur_node.forward[level]
        cur_node.markers.push(marker)
      end
    end

place_marker_on_outbound_path(marker, level, terminus) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 146
    def place_marker_on_outbound_path(marker, level, terminus)
      cur_node = self
      until cur_node == terminus
        cur_node.forward_markers[level].push(marker)
        cur_node.markers.push(marker)
        cur_node = cur_node.forward[level]
      end
    end

promote_markers(path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 43
    def promote_markers(path)
      promoted = []
      new_promoted = []
      0.upto(top_level) do |i|
        incoming_markers = path[i].forward_markers[i]
        markers.concat(incoming_markers)

        incoming_markers.each do |marker|
          if can_be_promoted_higher?(marker, i)
            new_promoted.push(marker)
            forward[i].delete_marker_from_path(marker, i, forward[i+1])
          else
            forward_markers[i].push(marker)
          end
        end

        promoted.each do |marker|
          if can_be_promoted_higher?(marker, i)
            new_promoted.push(marker)
            forward[i].delete_marker_from_path(marker, i, forward[i+1])
          else
            forward_markers[i].push(marker)
          end
        end

        promoted = new_promoted
        new_promoted = []
      end
    end

update_forward_pointers(path) click to toggle source

    # File lib/treetop/runtime/interval_skip_list/node.rb, line 36
    def update_forward_pointers(path)
      0.upto(top_level) do |i|
        forward[i] = path[i].forward[i]
        path[i].forward[i] = self
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.