|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcodec.containers.mkv.util.TLinkedList
public class TLinkedList
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 that you cannot put the same object into more than one list or more than once in the same list. You must also ensure that you only remove objects that are actually in the list. That is, if you have an object A and lists l1 and l2, you must ensure that you invoke List.remove(A) on the correct list. It is also forbidden to invoke List.remove() with an unaffiliated TLinkable (one that belongs to no list): this will destroy the list you invoke it on.
Created: Sat Nov 10 15:25:10 2001
gnu.trove.TLinkable| Nested Class Summary | |
|---|---|
class |
TLinkedList.IteratorImpl
A ListIterator that supports additions and deletions. |
| Field Summary | |
|---|---|
protected org.jcodec.containers.mkv.util.TLinkedList.TLinkable |
_head
the head of the list |
protected int |
_size
the number of elements in the list |
protected org.jcodec.containers.mkv.util.TLinkedList.TLinkable |
_tail
the tail of the list |
| Constructor Summary | |
|---|---|
TLinkedList()
Creates a new TLinkedList instance. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Object linkable)
Inserts linkable at index index in the list. |
boolean |
add(Object linkable)
Appends linkable to the end of the list. |
void |
addBefore(org.jcodec.containers.mkv.util.TLinkedList.TLinkable current,
org.jcodec.containers.mkv.util.TLinkedList.TLinkable newElement)
Inserts newElement into the list immediately before current. |
void |
addFirst(Object linkable)
Inserts linkable at the head of the list. |
void |
addLast(Object 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. |
TLinkedList.IteratorImpl |
first()
|
Object |
getFirst()
Returns the head of the list |
Object |
getLast()
Returns the tail of the list. |
protected void |
insert(int index,
Object linkable)
Implementation of index-based list insertions. |
boolean |
isEmpty()
|
TLinkedList.IteratorImpl |
listIterator()
|
TLinkedList.IteratorImpl |
listIterator(int index)
Returns an iterator positioned at index. |
boolean |
remove(Object o)
Removes the specified element from the list. |
Object |
removeFirst()
Remove and return the first element in the list. |
Object |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.jcodec.containers.mkv.util.TLinkedList.TLinkable _head
protected org.jcodec.containers.mkv.util.TLinkedList.TLinkable _tail
protected int _size
| Constructor Detail |
|---|
public TLinkedList()
TLinkedList instance.
| Method Detail |
|---|
public boolean isEmpty()
public TLinkedList.IteratorImpl first()
public TLinkedList.IteratorImpl listIterator()
public TLinkedList.IteratorImpl listIterator(int index)
index - an int value
ListIterator valuepublic int size()
int value
public void add(int index,
Object linkable)
index - an int valuelinkable - an object of type TLinkablepublic boolean add(Object linkable)
linkable - an object of type TLinkable
public void addFirst(Object linkable)
linkable - an object of type TLinkablepublic void addLast(Object linkable)
linkable - an object of type TLinkablepublic void clear()
public Object[] toArray()
Object[] valuepublic Object[] toUnlinkedArray()
Object[] valuepublic boolean contains(Object o)
o - an Object value
boolean valuepublic Object getFirst()
Object valuepublic Object getLast()
Object valuepublic Object removeFirst()
Object valuepublic Object removeLast()
Object value
protected void insert(int index,
Object linkable)
index - an int valuelinkable - an object of type TLinkablepublic boolean remove(Object o)
o - a TLinkable element already inserted in this list.
public void addBefore(org.jcodec.containers.mkv.util.TLinkedList.TLinkable current,
org.jcodec.containers.mkv.util.TLinkedList.TLinkable newElement)
current - a TLinkable value currently in the list.newElement - a TLinkable value to be added to
the list.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||