jade.util.leap
Class LinkedList

java.lang.Object
  |
  +--jade.util.leap.LinkedList
All Implemented Interfaces:
Collection, List, Serializable, java.io.Serializable

public class LinkedList
extends java.lang.Object
implements List, Serializable

The LEAP (environment-dependent) version of the &qote;java.util.ArrayList&qote; class. This class appears to be exactly the same in J2SE, PJAVA and MIDP. The internal implementation is different in the three cases however.

Version:
1.0, 29/09/00
Author:
Nicolas Lhuillier
See Also:
LinkedList, Serialized Form

Constructor Summary
LinkedList()
          Default Constructor, creates an empty List
 
Method Summary
 void add(int index, java.lang.Object o)
          Inserts the specified element at the specified position in this list
 boolean add(java.lang.Object o)
          Adds an element.
 void addFirst(java.lang.Object o)
          Inserts the given element at the beginning of this list.
 void addLast(java.lang.Object o)
          Appends the given element to the end of this list.
 void clear()
          Removes all of the elements from this list (optional operation).
 boolean contains(java.lang.Object o)
          Returns true if this list contains the specified element.
 java.lang.Object get(int index)
          Returns the element at the specified position in this list.
 int indexOf(java.lang.Object o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 boolean isEmpty()
          Checks if the collection contains elements.
 Iterator iterator()
          Returns an iterator over the elements in this collection.
 java.lang.Object remove(int index)
          Removes the element at the specified position in this list.
 boolean remove(java.lang.Object o)
          Removes one instance of the specified element.
 java.lang.Object removeFirst()
          Removes and returns the first element from this list.
 int size()
          Returns the number of elements in this collection.
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in this collection.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Default Constructor, creates an empty List

Method Detail

clear

public void clear()
Description copied from interface: List
Removes all of the elements from this list (optional operation). This list will be empty after this call returns.

Specified by:
clear in interface List
See Also:
interface

contains

public boolean contains(java.lang.Object o)
Description copied from interface: List
Returns true if this list contains the specified element.

Specified by:
contains in interface List
Parameters:
o - element whose presence in this list is to be tested.
Returns:
true if this list contains the specified element.
See Also:
interface

get

public java.lang.Object get(int index)
Description copied from interface: List
Returns the element at the specified position in this list.

Specified by:
get in interface List
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
See Also:
interface

indexOf

public int indexOf(java.lang.Object o)
Description copied from interface: List
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

Specified by:
indexOf in interface List
Parameters:
o - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
See Also:
interface

remove

public java.lang.Object remove(int index)
Description copied from interface: List
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.

Specified by:
remove in interface List
Parameters:
index - the index of the element to removed.
Returns:
the element previously at the specified position.
See Also:
interface

add

public boolean add(java.lang.Object o)
Description copied from interface: Collection
Adds an element.

Specified by:
add in interface Collection
Returns:
true if the element has been added.
See Also:
interface

add

public void add(int index,
                java.lang.Object o)
Inserts the specified element at the specified position in this list

Specified by:
add in interface List

isEmpty

public boolean isEmpty()
Description copied from interface: Collection
Checks if the collection contains elements.

Specified by:
isEmpty in interface Collection
Returns:
true if this collection contains no elements
See Also:
interface

remove

public boolean remove(java.lang.Object o)
Description copied from interface: Collection
Removes one instance of the specified element.

Specified by:
remove in interface Collection
Parameters:
o - the element to be removed
Returns:
true if the element has been removed
See Also:
interface

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

iterator

public Iterator iterator()
Description copied from interface: Collection
Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned.

Specified by:
iterator in interface Collection
Returns:
an Iterator over the elements in this collection
See Also:
interface

toArray

public java.lang.Object[] toArray()
Description copied from interface: Collection
Returns an array containing all of the elements in this collection.

Specified by:
toArray in interface Collection
Returns:
an array containing all of the elements in this collection
See Also:
interface

size

public int size()
Description copied from interface: Collection
Returns the number of elements in this collection.

Specified by:
size in interface Collection
Returns:
the number of elements in this collection.
See Also:
interface

removeFirst

public java.lang.Object removeFirst()
Removes and returns the first element from this list.

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

addFirst

public void addFirst(java.lang.Object 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(java.lang.Object 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.


JADE