class Linkedlist::Singly(T)
- Linkedlist::Singly(T)
- Reference
- Object
Defined in:
linkedlist/singly.crConstructors
-
.new
Intializes a singly linked list
Instance Method Summary
-
#find_element(element : SinglyNode(T)) : SinglyNode(T)
Returns the element if found or raises exception
-
#find_element(value : T) : SinglyNode(T)
Returns the first element with value or raises exception if not found
-
#find_element?(element : SinglyNode(T)) : SinglyNode(T) | Nil
Returns the element if found or nil if not found
-
#find_element?(value : T) : SinglyNode(T) | Nil
Returns the first element with value or nil if not found
-
#head
Returns the head of linked list
-
#insert_after(element : SinglyNode(T), mark : SinglyNode(T))
Inserts given element after the mark or raises exception if mark not found
-
#insert_after(value : T, mark : SinglyNode(T)) : SinglyNode(T)
Inserts new element after the mark or raises exception if mark not found
-
#insert_after?(value : T, mark : SinglyNode(T)) : SinglyNode(T) | Nil
Inserts new element after the mark or returns nil if mark not found
-
#insert_before(element : SinglyNode(T), mark : SinglyNode(T))
Inserts given element before the mark or returns nil if mark not found
-
#insert_before(value : T, mark : SinglyNode(T)) : SinglyNode(T)
Inserts new element before the mark or raises exception if mark not found
-
#insert_before?(value : T, mark : SinglyNode(T)) : SinglyNode(T) | Nil
Inserts new element before the mark or returns nil if mark not found
-
#insert_head(data : T)
Inserts new element at the head of the linked list
-
#insert_tail(data : T)
Inserts new element at the tail of the linked list
-
#length
Returns the length of linked list.
-
#move_after(element : SinglyNode(T), mark : SinglyNode(T))
Moves element after the mark, if element and mark are present and not equal
-
#move_before(element : SinglyNode(T), mark : SinglyNode(T))
Moves element before the mark, if element and mark are present and not equal
-
#move_to_back(element : SinglyNode(T))
Moves element to front if found.
-
#move_to_front(element : SinglyNode(T))
Moves element to front if found.
-
#previous_element?(element : SinglyNode(T)) : SinglyNode(T) | Nil
Returns the previous element if element found or nil if not found
-
#remove(element : SinglyNode(T)) : T
Removes an element from the linked list and returns the data
-
#remove?(element : SinglyNode(T)) : SinglyNode(T) | Nil
Removes an element from the linked list and returns the element
-
#tail
Returns the tail of linked list
Constructor Detail
Instance Method Detail
Returns the element if found or raises exception
Running time: O(n)
Returns the first element with value or raises exception if not found
Running time: O(n)
Returns the element if found or nil if not found
Running time: O(n)
Returns the first element with value or nil if not found
Running time: O(n)
Inserts given element after the mark or raises exception if mark not found
Running time: O(n)
Inserts new element after the mark or raises exception if mark not found
Running time: O(n)
Inserts new element after the mark or returns nil if mark not found
Running time: O(n)
Inserts given element before the mark or returns nil if mark not found
Running time: O(n)
Inserts new element before the mark or raises exception if mark not found
Running time: O(n)
Inserts new element before the mark or returns nil if mark not found
Running time: O(n)
Moves element after the mark, if element and mark are present and not equal
Running time: O(n)
Moves element before the mark, if element and mark are present and not equal
Running time: O(n)
Moves element to front if found. List is unmodified otherwise.
Running time: O(n)
Moves element to front if found. List is unmodified otherwise.
Running time: O(n)
Returns the previous element if element found or nil if not found
Running time: O(n)
Removes an element from the linked list and returns the data
Running time: O(n)
Removes an element from the linked list and returns the element
Running time: O(n)