Sha256: 2bd6342d0797c4f7cdb93beebe37f739a4e27bbd0966bd2ec039cc3eba64a6ff

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 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 #{Implementation::DIRECTIONS}, got #{direction}"
        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 #{Implementation::DIRECTIONS}, got #{direction}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
red-black-tree-0.1.7 lib/red_black_tree/node/left_right_element_referencers.rb
red-black-tree-0.1.6 lib/red_black_tree/node/left_right_element_referencers.rb