public class TLinkedList<T extends TLinkable<T>> extends AbstractSequentialList<T> implements Externalizable
A LinkedList implementation which holds instances of type TLinkable.
Using this implementation allows you to get java.util.LinkedList behavior (a doubly linked list, with Iterators that support insert and delete operations) without incurring the overhead of creating Node wrapper objects for every element in your list.
The requirement to achieve this time/space gain is that the Objects stored in the List implement the TLinkable interface.
The limitations are:
| Constructor and Description |
|---|
TLinkedList()
Creates a new
TLinkedList instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T linkable)
Inserts linkable at index index in the list.
|
boolean |
add(T linkable)
Appends linkable to the end of the list.
|
void |
addAfter(T current,
T newElement)
Inserts newElement into the list immediately after current.
|
void |
addBefore(T current,
T newElement)
Inserts newElement into the list immediately before current.
|
void |
addFirst(T linkable)
Inserts linkable at the head of the list.
|
void |
addLast(T linkable)
Adds linkable to the end of the list.
|
void |
clear()
Empties the list.
|
boolean |
contains(Object o)
A linear search for o in the list.
|
T |
get(int index) |
T |
getFirst()
Returns the head of the list
|
T |
getLast()
Returns the tail of the list.
|
T |
getNext(T current)
Return the node following the given node.
|
T |
getPrevious(T current)
Return the node preceding the given node.
|
ListIterator<T> |
listIterator(int index)
Returns an iterator positioned at index.
|
void |
readExternal(ObjectInput in) |
boolean |
remove(Object o)
Removes the specified element from the list.
|
T |
removeFirst()
Remove and return the first element in the list.
|
T |
removeLast()
Remove and return the last element in the list.
|
int |
size()
Returns the number of elements in the list.
|
Object[] |
toArray()
Copies the list's contents into a native array.
|
Object[] |
toUnlinkedArray()
Copies the list to a native array, destroying the next/previous links as
the copy is made.
|
T[] |
toUnlinkedArray(T[] a)
Returns a typed array of the objects in the set.
|
void |
writeExternal(ObjectOutput out) |
addAll, iterator, remove, setequals, hashCode, indexOf, lastIndexOf, listIterator, subListaddAll, containsAll, isEmpty, removeAll, retainAll, toArray, toStringaddAll, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArrayparallelStream, removeIf, streampublic ListIterator<T> listIterator(int index)
listIterator in interface List<T extends TLinkable<T>>listIterator in class AbstractSequentialList<T extends TLinkable<T>>index - an int valueListIterator valuepublic int size()
public void add(int index,
T linkable)
public boolean add(T linkable)
public void addFirst(T linkable)
linkable - an object of type TLinkablepublic void addLast(T linkable)
linkable - an object of type TLinkablepublic void clear()
public Object[] toArray()
public Object[] toUnlinkedArray()
Object[] valuepublic T[] toUnlinkedArray(T[] a)
a - an Object[] valueObject[] valuepublic boolean contains(Object o)
public T get(int index)
public T getFirst()
Object valuepublic T getLast()
Object valuepublic T getNext(T current)
NOTE: this should only be used with nodes contained in the list. The results are undefined with anything else.
current - The current nodepublic T getPrevious(T current)
NOTE: this should only be used with nodes contained in the list. The results are undefined with anything else.
current - The current nodepublic T removeFirst()
Object valuepublic T removeLast()
Object valuepublic boolean remove(Object o)
remove in interface Collection<T extends TLinkable<T>>remove in interface List<T extends TLinkable<T>>remove in class AbstractCollection<T extends TLinkable<T>>o - a TLinkable element already inserted in this list.public void addBefore(T current, T newElement)
current - a TLinkable value currently in the list.newElement - a TLinkable value to be added to the list.public void addAfter(T current, T newElement)
current - a TLinkable value currently in the list.newElement - a TLinkable value to be added to the list.public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionCopyright 2004-2020 Solace Corporation. All rights reserved.