Module org.eclipse.persistence.core
Class ExposedNodeLinkedList
- java.lang.Object
-
- org.eclipse.persistence.internal.helper.linkedlist.ExposedNodeLinkedList
-
- All Implemented Interfaces:
Iterable,Collection,List
public class ExposedNodeLinkedList extends Object implements List
INTERNAL: A custom implementation of a linked list. This list exposes the linked nodes directly to the developer. It allows nodes to be referenced in code for quick list manipulation (ie reshuffle, remove, or queuing) It is specifically used in the EclipseLink cache write lock mechanism in order to allow quick removal of objects from the list while still providing the getFirst() addLast() functionality of a queue. The alternative java classes LinkedList, LinkedHashMap do not provide both functional requirements.- Since:
- 10.0.3
- Author:
- Gordon Yorke
- See Also:
LinkedNode
-
-
Constructor Summary
Constructors Constructor Description ExposedNodeLinkedList()Constructs an empty list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Object object)booleanadd(Object object)booleanaddAll(int index, Collection collection)booleanaddAll(Collection collection)LinkedNodeaddFirst(Object o)Inserts the given contents at the beginning of this list.LinkedNodeaddLast(Object o)Appends the given contents to the end of this list.voidclear()Removes all of the contents from this list.booleancontains(Object o)Returnstrueif this list contains the specified contents.booleancontainsAll(Collection collection)Objectget(int index)ObjectgetFirst()Returns the first contents in this list.ObjectgetLast()Returns the last contents in this list.intindexOf(Object o)Returns the index in this list of the first occurrence of the specified contents, or -1 if the List does not contain this contents.booleanisEmpty()Iteratoriterator()intlastIndexOf(Object object)ListIteratorlistIterator()ListIteratorlistIterator(int index)voidmoveFirst(LinkedNode node)Allows a node to be efficiently moved first.Objectremove(int index)booleanremove(Object object)voidremove(LinkedNode n)Allows a node to be efficiently removed.booleanremoveAll(Collection collection)ObjectremoveFirst()Removes and returns the first contents from this list.ObjectremoveLast()Removes and returns the last contents from this list.booleanretainAll(Collection collection)Objectset(int index, Object value)intsize()Returns the number of contents in this list.ListsubList(int start, int end)Object[]toArray()Object[]toArray(Object[] array)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
-
-
-
Method Detail
-
toArray
public Object[] toArray(Object[] array)
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIteratorin interfaceList
-
listIterator
public ListIterator listIterator()
- Specified by:
listIteratorin interfaceList
-
iterator
public Iterator iterator()
-
retainAll
public boolean retainAll(Collection collection)
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList
-
removeAll
public boolean removeAll(Collection collection)
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList
-
containsAll
public boolean containsAll(Collection collection)
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList
-
addAll
public boolean addAll(Collection collection)
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList
-
addAll
public boolean addAll(int index, Collection collection)
-
remove
public boolean remove(Object object)
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList
-
add
public boolean add(Object object)
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
lastIndexOf
public int lastIndexOf(Object object)
- Specified by:
lastIndexOfin interfaceList
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceList
-
getFirst
public Object getFirst()
Returns the first contents in this list.- Returns:
- the first contents in this list. Null if this list is empty.
-
getLast
public Object getLast()
Returns the last contents in this list.- Returns:
- the last contents in this list. Null if this list is empty.
-
removeFirst
public Object removeFirst()
Removes and returns the first contents from this list.- Returns:
- the first contents from this list.
- Throws:
NoSuchElementException- if this list is empty.
-
removeLast
public Object removeLast()
Removes and returns the last contents from this list.- Returns:
- the last contents from this list.
- Throws:
NoSuchElementException- if this list is empty.
-
addFirst
public LinkedNode addFirst(Object o)
Inserts the given contents at the beginning of this list.- Parameters:
o- the contents to be inserted at the beginning of this list.
-
addLast
public LinkedNode addLast(Object o)
Appends the given contents to the end of this list. (Identical in function to theaddmethod; included only for consistency.)- Parameters:
o- the contents to be inserted at the end of this list.
-
contains
public boolean contains(Object o)
Returnstrueif this list contains the specified contents. More formally, returnstrueif and only if this list contains at least one contentsesuch that(o==null ? e==null : o.equals(e)).- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList- Parameters:
o- contents whose presence in this list is to be tested.- Returns:
trueif this list contains the specified contents.
-
size
public int size()
Returns the number of contents in this list.- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- Returns:
- the number of contents in this list.
-
clear
public void clear()
Removes all of the contents from this list.- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
indexOf
public int indexOf(Object o)
Returns the index in this list of the first occurrence of the specified contents, or -1 if the List does not contain this contents. 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.
-
remove
public void remove(LinkedNode n)
Allows a node to be efficiently removed.
-
moveFirst
public void moveFirst(LinkedNode node)
Allows a node to be efficiently moved first.
-
-