Double Linked List¶
-
class
ListNode
(prev, next, value)¶ Represents a List-Node
Creates a new List Node
Arguments: -
ListNode.
next
¶ Pointer to the next element
-
ListNode.
prev
¶ Pointer to the previous element
-
ListNode.
value
¶ The value of this node
-
-
class
DoubleLinkedList
()¶ Represents a double linked lists with its common operations
Creates a new linked list
-
DoubleLinkedList.
addHead
(value)¶ Adds a new element to the beginning of the list.
Arguments: - value (any) – The value you want to add to the list.
-
DoubleLinkedList.
addTail
(value)¶ Adds a new element at the list end.
Arguments: - value (any) – The value you want to add to the list
-
DoubleLinkedList.
append
(elem, newItem)¶ Append a new element after elem
Arguments: - elem (ListNode) – Element after which newItem should be appended
- newItem (any) – The item to append.
Returns: boolean – true on success
-
DoubleLinkedList.
delete
(value)¶ Searches for an element and deletes it.
Arguments: - value (any) – Value of the element you want to delete
-
DoubleLinkedList.
deleteHead
()¶ Deletes the current head element and sets the head pointer to the next element
-
DoubleLinkedList.
deleteNode
(elem)¶ Deletes a element from the list
The node must belong to the list. No checks are performend.
Arguments: - elem (ListNode) – A node from the list
Returns: boolean – true on success
-
DoubleLinkedList.
deleteTail
()¶ Deletes the current tail element and sets the tail pointer to the previous element
-
DoubleLinkedList.
get
(value)¶ Do a search on the linked list for value
Arguments: - value (any) – The value you want to search for.
Returns: ListNode – A Node object.
-
DoubleLinkedList.
getForwardIter
()¶ Returns a new
Forward Iterator
for this listReturns: ForwardDListIterator
-
DoubleLinkedList.
getReverseIter
()¶ Returns a new
Reverse Iterator
for this list.Returns: ReverseDListIterator
-