public class LinkedList extends Object implements List, Serializable
LinkedList
,
Serialized FormModifier and Type | Field and Description |
---|---|
private Vector |
hiddenList |
private List |
realHiddenList |
private static long |
serialVersionUID |
Constructor and Description |
---|
LinkedList()
Default Constructor, creates an empty List
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
Object o)
Inserts the specified element at the specified position in this list
|
boolean |
add(Object o)
Adds an element.
|
void |
addFirst(Object o)
Inserts the given element at the beginning of this list.
|
void |
addLast(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(Object o)
Returns true if this list contains the specified element.
|
Object |
get(int index)
Returns the element at the specified position in this list.
|
private List |
getData() |
int |
indexOf(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.
|
private void |
readObject(ObjectInputStream in)
A customized readObject() method is needed to ensure compatibility with
the J2ME version of this class in serialization/deserialization
operations
|
Object |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
remove(Object o)
Removes one instance of the specified element.
|
Object |
removeFirst()
Removes and returns the first element from this list.
|
private void |
setData(List data) |
int |
size()
Returns the number of elements in this collection.
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
String |
toString() |
private void |
writeObject(ObjectOutputStream out)
A customized writeObject() method is needed to ensure compatibility with
the J2ME version of this class in serialization/deserialization
operations
|
private transient List realHiddenList
private Vector hiddenList
private static final long serialVersionUID
public void clear()
List
public boolean contains(Object o)
List
public Object get(int index)
List
public int indexOf(Object o)
List
public Object remove(int index)
List
public boolean add(Object o)
Collection
add
in interface Collection
interface
public void add(int index, Object o)
public boolean isEmpty()
Collection
isEmpty
in interface Collection
interface
public boolean remove(Object o)
Collection
remove
in interface Collection
o
- the element to be removedinterface
public Iterator iterator()
Collection
iterator
in interface Collection
interface
public Object[] toArray()
Collection
toArray
in interface Collection
interface
public int size()
Collection
size
in interface Collection
interface
public Object removeFirst()
NoSuchElementException
- if this list is empty.public void addFirst(Object o)
o
- the element to be inserted at the beginning of this list.public void addLast(Object o)
o
- the element to be inserted at the end of this list.private void writeObject(ObjectOutputStream out) throws IOException
IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
private void setData(List data)
private List getData()