shadow:utility@List<V>, shadow:utility@Deque<V>
class LinkedList<V>
Class LinkedList<V>
stores a list of elements of type V
, implemented with a circular, doubly linked list as internal storage.
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
create() |
public |
() |
create(Equate<V> equater) |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
destroy() |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
(LinkedList<V>) |
add(V value) Adds an element to the end of the list. |
public |
(LinkedList<V>) |
addFirst(V element) Adds an element to the beginning of the list. |
public |
(LinkedList<V>) |
addLast(V element) Adds an element to the end of the list. |
public |
(LinkedList<V>) |
clear() Removes all elements from the list. |
public readonly |
(boolean) |
contains(V value) Checks to see if the list contains a particular element. |
public readonly |
(LinkedList<V>) |
copy(AddressMap addresses) |
public |
(V) |
delete(long index) Removes the element at the given index. |
public readonly |
(V) |
getFirst() Gets the element at the beginning of the list. |
public readonly |
(V) |
getLast() Gets the element at the end of the list. |
public readonly |
(V) |
index(long index) Retrieves the element at the given index. |
public |
() |
index(long index, V value) Stores an element into the given index. |
public readonly |
(long) |
indexOf(V value) Finds the first index where a particular element is present. |
public readonly |
(boolean) |
isEmpty() Checks whether or not the list is empty. |
public readonly |
(Iterator<V>) |
iterator() Creates an iterator to iterate over all the values in the list. |
public |
(boolean) |
remove(V value) Removes the first occurrence of an element. |
public |
(V) |
removeFirst() Removes the element at the beginning of the list. |
public |
(V) |
removeLast() Removes the element from the end of the list. |
public readonly |
(String) |
toString() Produces a |
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly get |
(int) |
size() Gets size of the list as an |
public readonly get locked |
(long) |
sizeLong() Gets size of the list as a |
public destroy() => ()
public add(V value) => (LinkedList<V>)
Adds an element to the end of the list. This operation is constant time.
value
- value of element
list after the add
public addFirst(V element) => (LinkedList<V>)
Adds an element to the beginning of the list. This operation is constant time.
element
- element to be added
list after the element is added
public addLast(V element) => (LinkedList<V>)
Adds an element to the end of the list. This operation is constant time.
element
- element to be added
list after the element is added
public clear() => (LinkedList<V>)
Removes all elements from the list. This operation is constant time.
list after being cleared
public readonly contains(V value) => (boolean)
Checks to see if the list contains a particular element.
value
- element to search for
true
if present
public readonly copy(AddressMap addresses) => (LinkedList<V>)
public delete(long index) => (V)
Removes the element at the given index. This operation is linear time in the worst case.
index
- index of element to remove
element being removed
IndexOutOfBoundsException
- if an illegal index is specified
public readonly getFirst() => (V)
Gets the element at the beginning of the list. This operation is constant time.
first element in the list
NoSuchElementException
- if the list is empty
public readonly getLast() => (V)
Gets the element at the end of the list. This operation is constant time.
last element in the list
NoSuchElementException
- if the list is empty
public readonly index(long index) => (V)
Retrieves the element at the given index. Legal indexes are from 0 to one less than the size of the list. This operation takes linear time in the worst case.
index
- location of element
element
IndexOutOfBoundsException
- if an illegal index is specified
public index(long index, V value) => ()
Stores an element into the given index. Legal indexes are from 0 to the size of the list. If an element is stored into the index corresponding to the size of the list, the list's size will increase by one. This operation is linear time in the worst case.
index
- location of element
value
- value of element
IndexOutOfBoundsException
- if an illegal index is specified
public readonly indexOf(V value) => (long)
Finds the first index where a particular element is present. If the element is not present, -1 will be returned.
value
- element to search for
index of element or -1 if not found
public readonly isEmpty() => (boolean)
Checks whether or not the list is empty.
true
if the list is empty
public readonly iterator() => (Iterator<V>)
Creates an iterator to iterate over all the values in the list.
iterator
public remove(V value) => (boolean)
Removes the first occurrence of an element. This operation is linear time in the worst case.
value
- value of element to remove
true
if the element was found and removed
public removeFirst() => (V)
Removes the element at the beginning of the list. This operation is constant time.
element being removed
NoSuchElementException
- if the list is empty
public removeLast() => (V)
Removes the element from the end of the list. This operation is constant time.
element being removed
NoSuchElementException
- if the list is empty
public readonly toString() => (String)
Produces a String
representation of the list, listing all elements in order.
String
representation