SinglyLinkedList<T> class

Complexity of each operation

operation | complexity peekFirst | O(1) peekLast | O(1) isEmpty | O(1) isNotEmpty | O(1) length | O(1) contains | O(n) peek | O(n) getAll | O(n) addFirst | O(1) addLast | O(1) remove | O(n) removeFirst | O(1) removeLast | O(n) clear | O(1) Implementation of Singly LinkedList

Constructors

SinglyLinkedList()

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if there are no nodes in this list.
no setter
isNotEmpty bool
Returns true if there is at least one node in this list.
no setter
length int
Returns the number of nodes in this list.
no setter
peekFirst → T?
Returns the first node data.
no setter
peekLast → T?
Returns the last node data.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addFirst(T obj) → void
Adds a node to the beginning of the list.
addLast(T obj) → void
Adds a node to the end of the list.
clear() → void
Removes all nodes from this list.
contains(T obj) bool
Returns true if this list contains the specified node data.
getAll() List<T?>?
Gets all nodes data in this LinkedList and then returns them as type List. This method returns null if the list is empty.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek(int index) → T?
Returns the node data at the specified position. This method returns null if the specified position contains nothing or the list is empty.
remove(T obj) → T?
Removes a specific node from this list and then returns its data. This method returns null if the list is empty or the specific node does not exists.
removeFirst() → T?
Removes and returns the first node data from this list. This method returns null if the list is empty.
removeLast() → T?
Removes and returns the last node data from this list. This method returns null if the list is empty.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited