shadow:utility

Class LinkedList<V>

Parent class

shadow:standard@Object

Interfaces

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.

Create Summary

Modifiers Return Types Method and Description
public () create()
public () create(Equate<V> equater)

Destroy Summary

Modifiers Return Types Method and Description
public () destroy()

Method Summary

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 String representation of the list, listing all elements in order.

Property Summary

Modifiers Return Types Method and Description
public readonly get (int) size()

Gets size of the list as an int.

public readonly get locked (long) sizeLong()

Gets size of the list as a long.

Create Detail

create

public create() => ()

create

public create(Equate<V> equater) => ()

Destroy Detail

destroy

public destroy() => ()

Method Detail

add

public add(V value) => (LinkedList<V>)

Adds an element to the end of the list. This operation is constant time.

Parameters

value - value of element

Returns

list after the add

addFirst

public addFirst(V element) => (LinkedList<V>)

Adds an element to the beginning of the list. This operation is constant time.

Parameters

element - element to be added

Returns

list after the element is added

addLast

public addLast(V element) => (LinkedList<V>)

Adds an element to the end of the list. This operation is constant time.

Parameters

element - element to be added

Returns

list after the element is added

clear

public clear() => (LinkedList<V>)

Removes all elements from the list. This operation is constant time.

Returns

list after being cleared

contains

public readonly contains(V value) => (boolean)

Checks to see if the list contains a particular element.

Parameters

value - element to search for

Returns

true if present

copy

public readonly copy(AddressMap addresses) => (LinkedList<V>)

delete

public delete(long index) => (V)

Removes the element at the given index. This operation is linear time in the worst case.

Parameters

index - index of element to remove

Returns

element being removed

Throws

IndexOutOfBoundsException - if an illegal index is specified

getFirst

public readonly getFirst() => (V)

Gets the element at the beginning of the list. This operation is constant time.

Returns

first element in the list

Throws

NoSuchElementException - if the list is empty

getLast

public readonly getLast() => (V)

Gets the element at the end of the list. This operation is constant time.

Returns

last element in the list

Throws

NoSuchElementException - if the list is empty

index

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.

Parameters

index - location of element

Returns

element

Throws

IndexOutOfBoundsException - if an illegal index is specified

index

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.

Parameters

index - location of element

value - value of element

Throws

IndexOutOfBoundsException - if an illegal index is specified

indexOf

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.

Parameters

value - element to search for

Returns

index of element or -1 if not found

isEmpty

public readonly isEmpty() => (boolean)

Checks whether or not the list is empty.

Returns

true if the list is empty

iterator

public readonly iterator() => (Iterator<V>)

Creates an iterator to iterate over all the values in the list.

Returns

iterator

remove

public remove(V value) => (boolean)

Removes the first occurrence of an element. This operation is linear time in the worst case.

Parameters

value - value of element to remove

Returns

true if the element was found and removed

removeFirst

public removeFirst() => (V)

Removes the element at the beginning of the list. This operation is constant time.

Returns

element being removed

Throws

NoSuchElementException - if the list is empty

removeLast

public removeLast() => (V)

Removes the element from the end of the list. This operation is constant time.

Returns

element being removed

Throws

NoSuchElementException - if the list is empty

toString

public readonly toString() => (String)

Produces a String representation of the list, listing all elements in order.

Returns

String representation

Property Detail

size

public readonly get size() => (int)

Gets size of the list as an int.

sizeLong

public readonly get locked sizeLong() => (long)

Gets size of the list as a long.