Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.adfnmc.java.util
Class LinkedList

java.lang.Object
  extended by oracle.adfnmc.java.util.AbstractCollection
      extended by oracle.adfnmc.java.util.AbstractList
          extended by oracle.adfnmc.java.util.AbstractSequentialList
              extended by oracle.adfnmc.java.util.LinkedList
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, Queue

public class LinkedList
extends AbstractSequentialList
implements List, Queue, Cloneable, Serializable

LinkedList is an implementation of List, backed by a linked list. All optional operations are supported, adding, removing and replacing. The elements can be any objects.

Since:
1.2

Field Summary
 
Fields inherited from class oracle.adfnmc.java.util.AbstractList
modCount
 
Constructor Summary
LinkedList()
          Constructs a new empty instance of LinkedList.
LinkedList(Collection collection)
          Constructs a new instance of LinkedList that holds all of the elements contained in the supplied collection argument.
 
Method Summary
 void add(int location, java.lang.Object object)
          Inserts the specified object into this LinkedList at the specified location.
 boolean add(java.lang.Object object)
          Adds the specified object at the end of this LinkedList.
 boolean addAll(Collection collection)
          Adds the objects in the specified Collection to this LinkedList.
 boolean addAll(int location, Collection collection)
          Inserts the objects in the specified Collection at the specified location in this LinkedList.
 void addFirst(java.lang.Object object)
          Adds the specified object at the beginning of this LinkedList.
 void addLast(java.lang.Object object)
          Adds the specified object at the end of this LinkedList.
 void clear()
          Removes all elements from this LinkedList, leaving it empty.
 java.lang.Object clone()
          Answers a new LinkedList with the same elements and size as this LinkedList.
 boolean contains(java.lang.Object object)
          Searches this LinkedList for the specified object.
 java.lang.Object element()
          Gets but not removes the element in the head of the queue.
 java.lang.Object get(int location)
          Answers the element at the specified location in this List.
 java.lang.Object getFirst()
          Answers the first element in this LinkedList.
 java.lang.Object getLast()
          Answers the last element in this LinkedList.
 int indexOf(java.lang.Object object)
          Searches this LinkedList for the specified object and returns the index of the first occurrence.
 int lastIndexOf(java.lang.Object object)
          Searches this LinkedList for the specified object and returns the index of the last occurrence.
 ListIterator listIterator(int location)
          Answers a ListIterator on the elements of this LinkedList.
 boolean offer(java.lang.Object o)
          Inserts the specified element into the queue provided that the condition allows such an operation.
 java.lang.Object peek()
          Gets but not removes the element in the head of the queue, or throws exception if there is no element in the queue.
 java.lang.Object poll()
          Gets and removes the element in the head of the queue, or returns null if there is no element in the queue.
 java.lang.Object remove()
          Gets and removes the element in the head of the queue.
 java.lang.Object remove(int location)
          Removes the object at the specified location from this LinkedList.
 boolean remove(java.lang.Object object)
          Removes the first occurrence of the specified object from this Collection.
 java.lang.Object removeFirst()
          Removes the first object from this LinkedList.
 java.lang.Object removeLast()
          Removes the last object from this LinkedList.
 java.lang.Object set(int location, java.lang.Object object)
          Replaces the element at the specified location in this LinkedList with the specified object.
 int size()
          Answers the number of elements in this LinkedList.
 java.lang.Object[] toArray()
          Answers a new array containing all elements contained in this LinkedList.
 java.lang.Object[] toArray(java.lang.Object[] contents)
          Answers an array containing all elements contained in this LinkedList.
 
Methods inherited from class oracle.adfnmc.java.util.AbstractSequentialList
iterator
 
Methods inherited from class oracle.adfnmc.java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class oracle.adfnmc.java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.adfnmc.java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

LinkedList

public LinkedList()
Constructs a new empty instance of LinkedList.


LinkedList

public LinkedList(Collection collection)
Constructs a new instance of LinkedList that holds all of the elements contained in the supplied collection argument. The order of the elements in this new LinkedList will be determined by the iteration order of collection.

Parameters:
collection - the collection of elements to add
Method Detail

add

public void add(int location,
                java.lang.Object object)
Inserts the specified object into this LinkedList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this LinkedList, the object is added at the end.

Specified by:
add in interface List
Overrides:
add in class AbstractSequentialList
Parameters:
location - the index at which to insert
object - the object to add
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

add

public boolean add(java.lang.Object object)
Adds the specified object at the end of this LinkedList.

Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class AbstractList
Parameters:
object - the object to add
Returns:
true

addAll

public boolean addAll(int location,
                      Collection collection)
Inserts the objects in the specified Collection at the specified location in this LinkedList. The objects are added in the order they are returned from the Collection iterator.

Specified by:
addAll in interface List
Overrides:
addAll in class AbstractSequentialList
Parameters:
location - the index at which to insert
collection - the Collection of objects
Returns:
true if this LinkedList is modified, false otherwise
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || > size()

addAll

public boolean addAll(Collection collection)
Adds the objects in the specified Collection to this LinkedList.

Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Overrides:
addAll in class AbstractCollection
Parameters:
collection - the Collection of objects
Returns:
true if this LinkedList is modified, false otherwise

addFirst

public void addFirst(java.lang.Object object)
Adds the specified object at the beginning of this LinkedList.

Parameters:
object - the object to add

addLast

public void addLast(java.lang.Object object)
Adds the specified object at the end of this LinkedList.

Parameters:
object - the object to add

clear

public void clear()
Removes all elements from this LinkedList, leaving it empty.

Specified by:
clear in interface Collection
Specified by:
clear in interface List
Overrides:
clear in class AbstractList
See Also:
List.isEmpty(), size

clone

public java.lang.Object clone()
Answers a new LinkedList with the same elements and size as this LinkedList.

Returns:
a shallow copy of this LinkedList
See Also:
Cloneable

contains

public boolean contains(java.lang.Object object)
Searches this LinkedList for the specified object.

Specified by:
contains in interface Collection
Specified by:
contains in interface List
Overrides:
contains in class AbstractCollection
Parameters:
object - the object to search for
Returns:
true if object is an element of this LinkedList, false otherwise

get

public java.lang.Object get(int location)
Description copied from class: AbstractSequentialList
Answers the element at the specified location in this List.

Specified by:
get in interface List
Overrides:
get in class AbstractSequentialList
Parameters:
location - the index of the element to return
Returns:
the element at the specified location

getFirst

public java.lang.Object getFirst()
Answers the first element in this LinkedList.

Returns:
the first element
Throws:
java.util.NoSuchElementException - when this LinkedList is empty

getLast

public java.lang.Object getLast()
Answers the last element in this LinkedList.

Returns:
the last element
Throws:
java.util.NoSuchElementException - when this LinkedList is empty

indexOf

public int indexOf(java.lang.Object object)
Searches this LinkedList for the specified object and returns the index of the first occurrence.

Specified by:
indexOf in interface List
Overrides:
indexOf in class AbstractList
Parameters:
object - the object to search for
Returns:
the index of the first occurrence of the object

lastIndexOf

public int lastIndexOf(java.lang.Object object)
Searches this LinkedList for the specified object and returns the index of the last occurrence.

Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class AbstractList
Parameters:
object - the object to search for
Returns:
the index of the last occurrence of the object

listIterator

public ListIterator listIterator(int location)
Answers a ListIterator on the elements of this LinkedList. The elements are iterated in the same order that they occur in the LinkedList. The iteration starts at the specified location.

Specified by:
listIterator in interface List
Specified by:
listIterator in class AbstractSequentialList
Parameters:
location - the index at which to start the iteration
Returns:
a ListIterator on the elements of this LinkedList
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()
See Also:
ListIterator

remove

public java.lang.Object remove(int location)
Removes the object at the specified location from this LinkedList.

Specified by:
remove in interface List
Overrides:
remove in class AbstractSequentialList
Parameters:
location - the index of the object to remove
Returns:
the removed object
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

remove

public boolean remove(java.lang.Object object)
Description copied from class: AbstractCollection
Removes the first occurrence of the specified object from this Collection. This operation traverses over the collection, looking for the specified object. Once the object is found, the object will be removed from the collection using the iterator's remove method. This collection will throw an UnsupportedOperationException if the iterator returned does not implement remove method, and the specified object is in this collection.

Specified by:
remove in interface Collection
Specified by:
remove in interface List
Overrides:
remove in class AbstractCollection
Parameters:
object - the object to remove
Returns:
true if this Collection is modified, false otherwise

removeFirst

public java.lang.Object removeFirst()
Removes the first object from this LinkedList.

Returns:
the removed object
Throws:
java.util.NoSuchElementException - when this LinkedList is empty

removeLast

public java.lang.Object removeLast()
Removes the last object from this LinkedList.

Returns:
the removed object
Throws:
java.util.NoSuchElementException - when this LinkedList is empty

set

public java.lang.Object set(int location,
                            java.lang.Object object)
Replaces the element at the specified location in this LinkedList with the specified object.

Specified by:
set in interface List
Overrides:
set in class AbstractSequentialList
Parameters:
location - the index at which to put the specified object
object - the object to add
Returns:
the previous element at the index
Throws:
java.lang.IndexOutOfBoundsException - when location < 0 || >= size()

size

public int size()
Answers the number of elements in this LinkedList.

Specified by:
size in interface Collection
Specified by:
size in interface List
Specified by:
size in class AbstractCollection
Returns:
the number of elements in this LinkedList

offer

public boolean offer(java.lang.Object o)
Description copied from interface: Queue
Inserts the specified element into the queue provided that the condition allows such an operation. The method is generally preferable to the collection.add(E), since the latter might throw an exception if the operation fails.

Specified by:
offer in interface Queue
Parameters:
o - the specified element to insert into the queue.
Returns:
true if the operation succeeds and false if it fails.

poll

public java.lang.Object poll()
Description copied from interface: Queue
Gets and removes the element in the head of the queue, or returns null if there is no element in the queue.

Specified by:
poll in interface Queue
Returns:
the element in the head of the queue or null if there is no element in the queue.

remove

public java.lang.Object remove()
Description copied from interface: Queue
Gets and removes the element in the head of the queue. Throws a NoSuchElementException if there is no element in the queue.

Specified by:
remove in interface Queue
Returns:
the element in the head of the queue.

peek

public java.lang.Object peek()
Description copied from interface: Queue
Gets but not removes the element in the head of the queue, or throws exception if there is no element in the queue.

Specified by:
peek in interface Queue
Returns:
the element in the head of the queue or null if there is no element in the queue.

element

public java.lang.Object element()
Description copied from interface: Queue
Gets but not removes the element in the head of the queue. Throws a NoSuchElementException if there is no element in the queue.

Specified by:
element in interface Queue
Returns:
the element in the head of the queue.

toArray

public java.lang.Object[] toArray()
Answers a new array containing all elements contained in this LinkedList.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class AbstractCollection
Returns:
an array of the elements from this LinkedList

toArray

public java.lang.Object[] toArray(java.lang.Object[] contents)
Answers an array containing all elements contained in this LinkedList. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this LinkedList, the array element following the collection elements is set to null.

Specified by:
toArray in interface Collection
Overrides:
toArray in class AbstractCollection
Parameters:
contents - the array
Returns:
an array of the elements from this LinkedList
Throws:
java.lang.ArrayStoreException - when the type of an element in this LinkedList cannot be stored in the type of the specified array

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.