com.tensegrity.generic.util
Class LinkedListInt

java.lang.Object
  extended bycom.tensegrity.generic.util.LinkedListInt

public final class LinkedListInt
extends java.lang.Object

A simple linkedlist class for the fundamental type int. The iterators will throw the runtime-exception ListModifiedException in case they detect themselves that they were modified since the iterator was instantiated. This is NOT RELIABLE in the context of a multithreaded application. Only proper synchronization provides memory-barriers in the java programming language. Thus this is merely a helpful technique that might detect errors in concurrent programming. Only in a serialized programming context, the programmer can rely on the exception being generated each time the array is illegaly modified.

Version:
$Id: LinkedListInt.java,v 1.10 2003/10/24 15:01:37 AndreasEbbert Exp $
Author:
S.Rutz

Nested Class Summary
 class LinkedListInt.Iterator
          LinkedList iterator class
 
Constructor Summary
LinkedListInt()
          Constructs an empty linked list.
 
Method Summary
 boolean add(int value)
          Adds an element with given value to the end of the list
 boolean addFirst(int value)
          Adds an element with given value before the beginning of the list.
 boolean addLast(int value)
          Adds an element with given value to the end of the list
 int getFirst()
          Returns the first element from the list.
 int getLast()
          Returns the last element from the list.
 int indexOf(int value)
          Searches a value's position in the list.
 LinkedListInt.Iterator iterator()
          Returns an iterator for this list
 boolean remove(int value)
          Removes the specified element.
 int removeFirst()
          Removes an element from the beginning of the list.
 int removeLast()
          Removes an element from the end of the list.
 int size()
          Gets the size of the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedListInt

public LinkedListInt()
Constructs an empty linked list.

Method Detail

size

public final int size()
Gets the size of the list.

Returns:
size of the list.

getFirst

public final int getFirst()
Returns the first element from the list.

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

getLast

public final int getLast()
Returns the last element from the list.

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

addFirst

public final boolean addFirst(int value)
Adds an element with given value before the beginning of the list.

Parameters:
value - the value of the element to add to the list.
Returns:
always true. This is to keep consistent with standard classes from standard library

addLast

public final boolean addLast(int value)
Adds an element with given value to the end of the list

Parameters:
value - the value of the element to add to the list.
Returns:
always true. this is to keep consistent with standard classes from standard library

removeFirst

public final int removeFirst()
Removes an element from the beginning of the list.

Returns:
the removed value

removeLast

public final int removeLast()
Removes an element from the end of the list.

Returns:
the removed value

remove

public boolean remove(int value)
Removes the specified element.

Parameters:
value - the value whose first occurence is to be removed.
Returns:
true if a removal took place, otherwise false.

add

public final boolean add(int value)
Adds an element with given value to the end of the list

Parameters:
value - the value of the element to add to the list.
Returns:
always true. This is to keep consistent with standard classes from standard library

iterator

public LinkedListInt.Iterator iterator()
Returns an iterator for this list

Returns:
iterator for this list

indexOf

public int indexOf(int value)
Searches a value's position in the list.

Parameters:
value - the value to search
Returns:
the index of the element or -1 if the value is not found.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.