Sha256: f7f461cde60041e59eed683be1bf1699505de120f6d345118e671707c3111eff

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

class RedBlackTree
  class Node
    module LeftRightElementReferencers # @private
      def [] direction
        case direction
        when Node::LEFT then @left
        when Node::RIGHT then @right
        else raise ArgumentError, "Direction must be one of #{DIRECTIONS}"
        end
      end

      def []= direction, node
        case direction
        when Node::LEFT then @left = node
        when Node::RIGHT then @right = node
        else raise ArgumentError, "Direction must be one of #{DIRECTIONS}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
red-black-tree-0.1.2 lib/red_black_tree/node/left_right_element_referencers.rb
red-black-tree-0.1.1 lib/red_black_tree/node/left_right_element_referencers.rb
red-black-tree-0.1.0 lib/red_black_tree/node/left_right_element_referencers.rb