Package ptolemy.actor.gt.data
Class FastLinkedList<E>
- java.lang.Object
-
- ptolemy.actor.gt.data.FastLinkedList<E>
-
- Type Parameters:
E- The element type of this linked list.
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>
- Direct Known Subclasses:
GraphAnalyzer.IndexedLists
public class FastLinkedList<E> extends java.lang.Object implements java.util.Collection<E>A linked list that provides efficient add and removal functions.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Thomas Huining Feng
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classFastLinkedList.EntryAn entry in this linked list that contains an element.
-
Constructor Summary
Constructors Constructor Description FastLinkedList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E element)Add an element to the end of this linked list.booleanaddAll(java.util.Collection<? extends E> collection)Add all the elements of the given collection to the end of this linked list.voidaddEntryAfter(FastLinkedList.Entry entry, FastLinkedList.Entry previousEntry)Add an entry after previousEntry, or add the entry to the head if previousEntry is null.voidaddEntryBefore(FastLinkedList.Entry entry, FastLinkedList.Entry nextEntry)Add an entry before nextEntry, or add the entry to the tail if nextEntry is null.voidaddEntryToHead(FastLinkedList.Entry entry)Add an entry to the head of this linked list.voidaddEntryToTail(FastLinkedList.Entry entry)Add an entry to the tail of this linked list.voidclear()Clear this linked list.booleancontains(java.lang.Object element)Test whether this linked list has the given element in an entry.booleancontainsAll(java.util.Collection<?> collection)Test whether this linked list has all the elements of the given collection.FastLinkedList.EntryfindEntry(E element)Find an entry with the given element and return it.FastLinkedList.EntrygetHead()Get the head entry.FastLinkedList.EntrygetTail()Get the tail entry.booleanisEmpty()Test whether this collection is empty.java.util.Iterator<E>iterator()Not implemented.booleanremove(java.lang.Object element)Remove the first entry that has the given element.booleanremoveAll(java.util.Collection<?> collection)Remove all the elements of the collection from this linked list.booleanremoveAllAfter(FastLinkedList.Entry entry)Remove all entries after the given entry.booleanremoveAllBefore(FastLinkedList.Entry entry)Remove all entries before the given entry.booleanretainAll(java.util.Collection<?> collection)Retain all elements of the given collection, but remove entries whose elements are not in the collection.intsize()Get the size of this linked list.java.lang.Object[]toArray()Return an array that contains all the elements in this linked list.<T> T[]toArray(T[] array)Store all the elements in this linked list into the given array if its size is enough for the storage, or create a new array of the same type as the given array for the storage and return it.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
add
public boolean add(E element)
Add an element to the end of this linked list.- Specified by:
addin interfacejava.util.Collection<E>- Parameters:
element- The element to be added.- Returns:
- Always true.
-
addAll
public boolean addAll(java.util.Collection<? extends E> collection)
Add all the elements of the given collection to the end of this linked list.- Specified by:
addAllin interfacejava.util.Collection<E>- Parameters:
collection- The collection.- Returns:
- Always true.
-
addEntryAfter
public void addEntryAfter(FastLinkedList.Entry entry, FastLinkedList.Entry previousEntry)
Add an entry after previousEntry, or add the entry to the head if previousEntry is null.- Parameters:
entry- The entry to be added.previousEntry- The previous entry.
-
addEntryBefore
public void addEntryBefore(FastLinkedList.Entry entry, FastLinkedList.Entry nextEntry)
Add an entry before nextEntry, or add the entry to the tail if nextEntry is null.- Parameters:
entry- The entry to be added.nextEntry- The next entry.
-
addEntryToHead
public void addEntryToHead(FastLinkedList.Entry entry)
Add an entry to the head of this linked list.- Parameters:
entry- The entry to be added.
-
addEntryToTail
public void addEntryToTail(FastLinkedList.Entry entry)
Add an entry to the tail of this linked list.- Parameters:
entry- The entry to be added.
-
clear
public void clear()
Clear this linked list.- Specified by:
clearin interfacejava.util.Collection<E>
-
contains
public boolean contains(java.lang.Object element)
Test whether this linked list has the given element in an entry.- Specified by:
containsin interfacejava.util.Collection<E>- Parameters:
element- The element.- Returns:
- true if the element is found.
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
Test whether this linked list has all the elements of the given collection.- Specified by:
containsAllin interfacejava.util.Collection<E>- Parameters:
collection- The collection.- Returns:
- true if all the elements are found.
-
findEntry
public FastLinkedList.Entry findEntry(E element)
Find an entry with the given element and return it. Return null if not found.- Parameters:
element- The element.- Returns:
- The entry.
-
getHead
public FastLinkedList.Entry getHead()
Get the head entry.- Returns:
- The head entry.
-
getTail
public FastLinkedList.Entry getTail()
Get the tail entry.- Returns:
- The tail entry.
-
isEmpty
public boolean isEmpty()
Test whether this collection is empty.- Specified by:
isEmptyin interfacejava.util.Collection<E>- Returns:
- true if this collection is empty.
-
iterator
public java.util.Iterator<E> iterator()
Not implemented.
-
remove
public boolean remove(java.lang.Object element)
Remove the first entry that has the given element.- Specified by:
removein interfacejava.util.Collection<E>- Parameters:
element- The element.- Returns:
- true if an entry is removed, or false if an entry cannot be found.
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
Remove all the elements of the collection from this linked list.- Specified by:
removeAllin interfacejava.util.Collection<E>- Parameters:
collection- The collection.- Returns:
- true if this linked list is altered, or false if no entry is removed.
-
removeAllAfter
public boolean removeAllAfter(FastLinkedList.Entry entry)
Remove all entries after the given entry.- Parameters:
entry- The entry, which must be contained in this linked list.- Returns:
- true if this linked list is altered, or false if no entry is removed.
-
removeAllBefore
public boolean removeAllBefore(FastLinkedList.Entry entry)
Remove all entries before the given entry.- Parameters:
entry- The entry, which must be contained in this linked list.- Returns:
- true if this linked list is altered, or false if no entry is removed.
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
Retain all elements of the given collection, but remove entries whose elements are not in the collection.- Specified by:
retainAllin interfacejava.util.Collection<E>- Parameters:
collection- The collection.- Returns:
- true if this linked list is altered, or false if no entry is removed.
-
size
public int size()
Get the size of this linked list.- Specified by:
sizein interfacejava.util.Collection<E>- Returns:
- The size.
-
toArray
public java.lang.Object[] toArray()
Return an array that contains all the elements in this linked list.- Specified by:
toArrayin interfacejava.util.Collection<E>- Returns:
- The array.
-
toArray
public <T> T[] toArray(T[] array)
Store all the elements in this linked list into the given array if its size is enough for the storage, or create a new array of the same type as the given array for the storage and return it.- Specified by:
toArrayin interfacejava.util.Collection<E>- Type Parameters:
T- The element type of the array.- Parameters:
array- The array.- Returns:
- The given array, or a new array if the given array is not big enough.
-
-