infovis.utils
Class IntLinkedList

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.colt.list.AbstractCollection
          extended by cern.colt.list.AbstractList
              extended by cern.colt.list.AbstractIntList
                  extended by infovis.utils.IntLinkedList
All Implemented Interfaces:
IntBufferConsumer, Serializable, Cloneable

public class IntLinkedList
extends AbstractIntList

Class IntLinkedList

Version:
$Revision: 1.1 $
Author:
Jean-Daniel Fekete
See Also:
Serialized Form

Field Summary
 
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
 
Constructor Summary
IntLinkedList()
           
 
Method Summary
 void add(int o)
          Appends the specified element to the end of this list.
 void add(int index, int element)
          Inserts the specified element at the specified position in this list.
 boolean addAll(AbstractIntList c)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
 boolean addAll(int index, AbstractIntList c)
          Inserts all of the elements in the specified collection into this list, starting at the specified position.
 void addFirst(int o)
          Inserts the given element at the beginning of this list.
 void addLast(int o)
          Appends the given element to the end of this list.
 void clear()
          Removes all of the elements from this list.
 boolean contains(int o)
          Returns true if this list contains the specified element.
 void delete(int o)
          Removes the first occurrence of the specified element in this list.
 void ensureCapacity(int minCapacity)
           
 int get(int index)
          Returns the element at the specified position in this list.
 int getFirst()
          Returns the first element in this list.
 int getLast()
          Returns the last element in this list.
 int getQuick(int index)
           
 int indexOf(int o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element.
 int lastIndexOf(int o)
          Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.
 RowIterator listIterator(int index)
          Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list.
 int removeAt(int index)
          Removes the element at the specified position in this list.
 int removeFirst()
          Removes and returns the first element from this list.
 int removeLast()
          Removes and returns the last element from this list.
 void set(int index, int element)
          Replaces the element at the specified position in this list with the specified element.
 void setQuick(int index, int element)
           
 int size()
          Returns the number of elements in this list.
 
Methods inherited from class cern.colt.list.AbstractIntList
addAllOf, addAllOfFromTo, beforeInsert, beforeInsertAllOfFromTo, binarySearch, binarySearchFromTo, clone, elements, elements, equals, fillFromToWith, forEach, indexOfFromTo, lastIndexOfFromTo, mergeSortFromTo, mergeSortFromTo, partFromTo, quickSortFromTo, quickSortFromTo, removeAll, removeFromTo, replaceFromToWithFrom, replaceFromToWithFromTo, replaceFromWith, retainAll, reverse, shuffleFromTo, times, toList, toString
 
Methods inherited from class cern.colt.list.AbstractList
addAllOf, beforeInsertAllOf, mergeSort, quickSort, remove, setSize, shuffle, sort, sortFromTo, trimToSize
 
Methods inherited from class cern.colt.list.AbstractCollection
isEmpty
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntLinkedList

public IntLinkedList()
Method Detail

ensureCapacity

public void ensureCapacity(int minCapacity)
Specified by:
ensureCapacity in class AbstractIntList

getQuick

public int getQuick(int index)
Specified by:
getQuick in class AbstractIntList

setQuick

public void setQuick(int index,
                     int element)
Specified by:
setQuick in class AbstractIntList

getFirst

public int getFirst()
Returns the first element in this list.

Returns:
the first element in this list.
Throws:
NoSuchElementException - if this list is empty.

getLast

public int getLast()
Returns the last element in this list.

Returns:
the last element in this list.
Throws:
NoSuchElementException - if this list is empty.

removeFirst

public int removeFirst()
Removes and returns the first element from this list.

Returns:
the first element from this list.
Throws:
NoSuchElementException - if this list is empty.

removeLast

public int removeLast()
Removes and returns the last element from this list.

Returns:
the last element from this list.
Throws:
NoSuchElementException - if this list is empty.

addFirst

public void addFirst(int o)
Inserts the given element at the beginning of this list.

Parameters:
o - the element to be inserted at the beginning of this list.

addLast

public void addLast(int o)
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

Parameters:
o - the element to be inserted at the end of this list.

contains

public boolean contains(int o)
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).

Overrides:
contains in class AbstractIntList
Parameters:
o - element whose presence in this list is to be tested.
Returns:
true if this list contains the specified element.

size

public int size()
Returns the number of elements in this list.

Overrides:
size in class AbstractIntList
Returns:
the number of elements in this list.

add

public void add(int o)
Appends the specified element to the end of this list.

Overrides:
add in class AbstractIntList
Parameters:
o - element to be appended to this list.

delete

public void delete(int o)
Removes the first occurrence of the specified element in this list. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).

Overrides:
delete in class AbstractIntList
Parameters:
o - element to be removed from this list, if present.

addAll

public boolean addAll(AbstractIntList c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)

Parameters:
c - the elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.
Throws:
NullPointerException - if the specified collection is null.

addAll

public boolean addAll(int index,
                      AbstractIntList c)
Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.

Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.
Throws:
IndexOutOfBoundsException - if the specified index is out of range ( index < 0 || index > size()).
NullPointerException - if the specified collection is null.

clear

public void clear()
Removes all of the elements from this list.

Overrides:
clear in class AbstractList

get

public int get(int index)
Returns the element at the specified position in this list.

Overrides:
get in class AbstractIntList
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range ( index < 0 || index >= size()).

set

public void set(int index,
                int element)
Replaces the element at the specified position in this list with the specified element.

Overrides:
set in class AbstractIntList
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range ( index < 0 || index >= size()).

add

public void add(int index,
                int element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range ( index < 0 || index > size()).

removeAt

public int removeAt(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters:
index - the index of the element to removed.
Returns:
the element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range ( index < 0 || index >= size()).

indexOf

public int indexOf(int o)
Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Overrides:
indexOf in class AbstractIntList
Parameters:
o - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if the list does not contain this element.

lastIndexOf

public int lastIndexOf(int o)
Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Overrides:
lastIndexOf in class AbstractIntList
Parameters:
o - element to search for.
Returns:
the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.

listIterator

public RowIterator listIterator(int index)
Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. Obeys the general contract of List.listIterator(int).

The list-iterator is fail-fast : if the list is structurally modified at any time after the Iterator is created, in any way except through the list-iterator's own remove or add methods, the list-iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.

Parameters:
index - index of first element to be returned from the list-iterator (by a call to next).
Returns:
a ListIterator of the elements in this list (in proper sequence), starting at the specified position in the list.
Throws:
IndexOutOfBoundsException - if index is out of range ( index < 0 || index > size()).
See Also:
List.listIterator(int)


Copyright 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.