Class: DoublyLinkedlist::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/doubly_linkedlist/node.rb

Overview

Creates a node with value and links to next/previous nodes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Node

Initializes a node with the given object as its value.

Parameters:

  • value (Object)

    the value to be set as node value.



15
16
17
# File 'lib/doubly_linkedlist/node.rb', line 15

def initialize(value)
  @value = value
end

Instance Attribute Details

#nextNode

Returns the next/previous node object.

Returns:

  • (Node)

    the next/previous node object.



10
11
12
# File 'lib/doubly_linkedlist/node.rb', line 10

def next
  @next
end

#prevNode

Returns the next/previous node object.

Returns:

  • (Node)

    the next/previous node object.



10
11
12
# File 'lib/doubly_linkedlist/node.rb', line 10

def prev
  @prev
end

#valueObject (readonly)

Returns the node value.

Returns:

  • (Object)

    the node value.



7
8
9
# File 'lib/doubly_linkedlist/node.rb', line 7

def value
  @value
end