Class: RubyDataStructures::SinglyLinkedList::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/RubyDataStructures/singly_linked_list/element.rb

Direct Known Subclasses

DoublyLinkedList::Element

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list, key) ⇒ Element

Initializes an Element of SinglyLinkedList Arguments: list => Instance of SinglyLinkedList to which the element belongs to key => Value to be stored in the element.



9
10
11
12
# File 'lib/RubyDataStructures/singly_linked_list/element.rb', line 9

def initialize(list, key)
  @list = list
  @key = key
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



2
3
4
# File 'lib/RubyDataStructures/singly_linked_list/element.rb', line 2

def key
  @key
end

#nextObject

Returns the value of attribute next.



3
4
5
# File 'lib/RubyDataStructures/singly_linked_list/element.rb', line 3

def next
  @next
end