Package org.apache.commons.pool.impl
Class CursorableSubList<E>
java.lang.Object
org.apache.commons.pool.impl.CursorableLinkedList<E>
org.apache.commons.pool.impl.CursorableSubList<E>
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,List<E>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.pool.impl.CursorableLinkedList
CursorableLinkedList.Cursor, CursorableLinkedList.Listable<E>, CursorableLinkedList.ListIter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CursorableLinkedList
<E> My underlying listprotected CursorableLinkedList.Listable
<E> The element in my underlying list following the last element in my list.protected CursorableLinkedList.Listable
<E> The element in my underlying list preceding the first element in my list.Fields inherited from class org.apache.commons.pool.impl.CursorableLinkedList
_cursors, _head, _modCount, _size
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Inserts the specified element at the specified position in this list.boolean
Appends the specified element to the end of this list.boolean
addAll
(int index, Collection<? extends E> c) Inserts all of the elements in the specified collection into this list at the specified position.boolean
addAll
(Collection<? extends E> c) Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specifiedCollection
'sIterator
.boolean
Inserts the specified element at the beginning of this list.boolean
Inserts the specified element at the end of this list.protected void
Test to see if my underlying list has been modified by some other process.void
clear()
Removes all of the elements from this list.boolean
Returns true if this list contains the specified element.boolean
containsAll
(Collection<?> c) Returns true if this list contains all of the elements of the specified collection.boolean
Compares the specified object with this list for equality.get
(int index) Returns the element at the specified position in this list.getFirst()
Returns the element at the beginning of this list.getLast()
Returns the element at the end of this list.int
hashCode()
Returns the hash code value for this list.int
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.protected CursorableLinkedList.Listable
<E> insertListable
(CursorableLinkedList.Listable<E> before, CursorableLinkedList.Listable<E> after, E value) Inserts a new value into my list, after the specified before element, and before the specified after elementboolean
isEmpty()
Returns true if this list contains no elements.iterator()
Returns a fail-fast iterator.int
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.Returns a fail-fast ListIterator.listIterator
(int index) Returns a fail-fast ListIterator.remove
(int index) Removes the element at the specified position in this list (optional operation).boolean
Removes the first occurrence in this list of the specified element.boolean
removeAll
(Collection<?> c) Removes from this list all the elements that are contained in the specified collection.Removes the first element of this list, if any.Removes the last element of this list, if any.protected void
Removes the givenCursorableLinkedList.Listable
from my list.boolean
retainAll
(Collection<?> c) Retains only the elements in this list that are contained in the specified collection.Replaces the element at the specified position in this list with the specified element.int
size()
Returns the number of elements in this list.subList
(int fromIndex, int toIndex) Returns a fail-fast sublist.Object[]
toArray()
Returns an array containing all of the elements in this list in proper sequence.<T> T[]
toArray
(T[] a) Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array.Methods inherited from class org.apache.commons.pool.impl.CursorableLinkedList
broadcastListableChanged, broadcastListableInserted, broadcastListableRemoved, cursor, cursor, getListableAt, invalidateCursors, registerCursor, toString, unregisterCursor
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Field Details
-
_list
My underlying list -
_pre
The element in my underlying list preceding the first element in my list. -
_post
The element in my underlying list following the last element in my list.
-
-
Constructor Details
-
CursorableSubList
CursorableSubList(CursorableLinkedList<E> list, int from, int to)
-
-
Method Details
-
clear
public void clear()Description copied from class:CursorableLinkedList
Removes all of the elements from this list. This list will be empty after this call returns (unless it throws an exception).- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceList<E>
- Overrides:
clear
in classCursorableLinkedList<E>
-
iterator
Description copied from class:CursorableLinkedList
Returns a fail-fast iterator. -
size
public int size()Description copied from class:CursorableLinkedList
Returns the number of elements in this list.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Overrides:
size
in classCursorableLinkedList<E>
- Returns:
- the number of elements in this list.
-
isEmpty
public boolean isEmpty()Description copied from class:CursorableLinkedList
Returns true if this list contains no elements.- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceList<E>
- Overrides:
isEmpty
in classCursorableLinkedList<E>
- Returns:
- true if this list contains no elements.
-
toArray
Description copied from class:CursorableLinkedList
Returns an array containing all of the elements in this list in proper sequence. Obeys the general contract of theCollection.toArray()
method.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceList<E>
- Overrides:
toArray
in classCursorableLinkedList<E>
- Returns:
- an array containing all of the elements in this list in proper sequence.
-
toArray
public <T> T[] toArray(T[] a) Description copied from class:CursorableLinkedList
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. Obeys the general contract of theCollection.toArray()
method.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceList<E>
- Overrides:
toArray
in classCursorableLinkedList<E>
- Parameters:
a
- the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- Returns:
- an array containing the elements of this list.
-
contains
Description copied from class:CursorableLinkedList
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceList<E>
- Overrides:
contains
in classCursorableLinkedList<E>
- Parameters:
o
- element whose presence in this list is to be tested.- Returns:
- true if this list contains the specified element.
-
remove
Description copied from class:CursorableLinkedList
Removes the first occurrence in this list of the specified element. If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceList<E>
- Overrides:
remove
in classCursorableLinkedList<E>
- Parameters:
o
- element to be removed from this list, if present.- Returns:
- true if this list contained the specified element.
-
removeFirst
Description copied from class:CursorableLinkedList
Removes the first element of this list, if any.- Overrides:
removeFirst
in classCursorableLinkedList<E>
-
removeLast
Description copied from class:CursorableLinkedList
Removes the last element of this list, if any.- Overrides:
removeLast
in classCursorableLinkedList<E>
-
addAll
Description copied from class:CursorableLinkedList
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specifiedCollection
'sIterator
. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceList<E>
- Overrides:
addAll
in classCursorableLinkedList<E>
- Parameters:
c
- collection whose elements are to be added to this list.- Returns:
- true if this list changed as a result of the call.
-
add
Description copied from class:CursorableLinkedList
Appends the specified element to the end of this list.- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceList<E>
- Overrides:
add
in classCursorableLinkedList<E>
- Parameters:
o
- element to be appended to this list.- Returns:
- true
-
addFirst
Description copied from class:CursorableLinkedList
Inserts the specified element at the beginning of this list. (Equivalent toadd(0,o)
).- Overrides:
addFirst
in classCursorableLinkedList<E>
- Parameters:
o
- element to be prepended to this list.- Returns:
- true
-
addLast
Description copied from class:CursorableLinkedList
Inserts the specified element at the end of this list. (Equivalent toCursorableLinkedList.add(java.lang.Object)
).- Overrides:
addLast
in classCursorableLinkedList<E>
- Parameters:
o
- element to be appended to this list.- Returns:
- true
-
removeAll
Description copied from class:CursorableLinkedList
Removes from this list all the elements that are contained in the specified collection.- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceList<E>
- Overrides:
removeAll
in classCursorableLinkedList<E>
- Parameters:
c
- collection that defines which elements will be removed from this list.- Returns:
- true if this list changed as a result of the call.
-
containsAll
Description copied from class:CursorableLinkedList
Returns true if this list contains all of the elements of the specified collection.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
- Overrides:
containsAll
in classCursorableLinkedList<E>
- Parameters:
c
- collection to be checked for containment in this list.- Returns:
- true if this list contains all of the elements of the specified collection.
-
addAll
Description copied from class:CursorableLinkedList
Inserts all of the elements in the specified collection into this list at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specifiedCollection
'sIterator
. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.) -
hashCode
public int hashCode()Description copied from class:CursorableLinkedList
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); }
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceList<E>
- Overrides:
hashCode
in classCursorableLinkedList<E>
- Returns:
- the hash code value for this list.
- See Also:
-
retainAll
Description copied from class:CursorableLinkedList
Retains only the elements in this list that are contained in the specified collection. In other words, removes from this list all the elements that are not contained in the specified collection.- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceList<E>
- Overrides:
retainAll
in classCursorableLinkedList<E>
- Parameters:
c
- collection that defines which elements this set will retain.- Returns:
- true if this list changed as a result of the call.
-
set
Description copied from class:CursorableLinkedList
Replaces the element at the specified position in this list with the specified element. -
equals
Description copied from class:CursorableLinkedList
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceList<E>
- Overrides:
equals
in classCursorableLinkedList<E>
- Parameters:
o
- the object to be compared for equality with this list.- Returns:
- true if the specified object is equal to this list.
-
get
Description copied from class:CursorableLinkedList
Returns the element at the specified position in this list. -
getFirst
Description copied from class:CursorableLinkedList
Returns the element at the beginning of this list.- Overrides:
getFirst
in classCursorableLinkedList<E>
-
getLast
Description copied from class:CursorableLinkedList
Returns the element at the end of this list.- Overrides:
getLast
in classCursorableLinkedList<E>
-
add
Description copied from class:CursorableLinkedList
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). -
listIterator
Description copied from class:CursorableLinkedList
Returns a fail-fast ListIterator.- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classCursorableLinkedList<E>
- See Also:
-
remove
Description copied from class:CursorableLinkedList
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list. -
indexOf
Description copied from class:CursorableLinkedList
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. 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. -
lastIndexOf
Description copied from class:CursorableLinkedList
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.- Specified by:
lastIndexOf
in interfaceList<E>
- Overrides:
lastIndexOf
in classCursorableLinkedList<E>
- Parameters:
o
- element to search for.- Returns:
- the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
-
listIterator
Description copied from class:CursorableLinkedList
Returns a fail-fast ListIterator.- Specified by:
listIterator
in interfaceList<E>
- Overrides:
listIterator
in classCursorableLinkedList<E>
- See Also:
-
subList
Description copied from class:CursorableLinkedList
Returns a fail-fast sublist. -
insertListable
protected CursorableLinkedList.Listable<E> insertListable(CursorableLinkedList.Listable<E> before, CursorableLinkedList.Listable<E> after, E value) Inserts a new value into my list, after the specified before element, and before the specified after element- Overrides:
insertListable
in classCursorableLinkedList<E>
- Returns:
- the newly created
CursorableLinkedList.Listable
-
removeListable
Removes the givenCursorableLinkedList.Listable
from my list.- Overrides:
removeListable
in classCursorableLinkedList<E>
-
checkForComod
Test to see if my underlying list has been modified by some other process. If it has, throws aConcurrentModificationException
, otherwise quietly returns.- Throws:
ConcurrentModificationException
-