Class CopyOnWriteArrayIdentityList<E>
- java.lang.Object
-
- org.apache.karaf.util.collections.CopyOnWriteArrayIdentityList<E>
-
- Type Parameters:
E- the element type
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,List<E>,RandomAccess
public class CopyOnWriteArrayIdentityList<E> extends Object implements List<E>, RandomAccess, Cloneable, Serializable
Implements aArrayListvariant that is thread-safe. All write operation result in a new copy of the underlying data being created. Iterators reflect the state of the CopyOnWriteArrayIdentityList at the time they were created. They are not updated to reflect subsequent changes to the list. In addition, these iterators cannot be used for modifying the underlying CopyOnWriteArrayIdentityList. In addition, elements are compared based on reference equality instead of object equality when comparing values.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CopyOnWriteArrayIdentityList()Creates a new, empty instance of CopyOnWriteArrayList.CopyOnWriteArrayIdentityList(E[] array)Creates a new instance of CopyOnWriteArrayList and fills it with the contents of a given array.CopyOnWriteArrayIdentityList(Collection<? extends E> c)Creates a new instance of CopyOnWriteArrayList and fills it with the contents of a given Collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E e)booleanadd(E e)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)intaddAllAbsent(Collection<? extends E> c)Adds to this CopyOnWriteArrayList all those elements from a given collection that are not yet part of the list.booleanaddIfAbsent(E e)Adds to this CopyOnWriteArrayList another element, given that this element is not yet part of the list.voidclear()Objectclone()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanequals(Object o)Eget(int index)inthashCode()intindexOf(E e, int index)Returns the index of a given element, starting the search from a given position in the list.intindexOf(Object o)booleanisEmpty()Iterator<E>iterator()intlastIndexOf(E e, int index)Returns the last index of a given element, starting the search from a given position in the list and going backwards.intlastIndexOf(Object o)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)Eset(int index, E e)intsize()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)StringtoString()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Constructor Detail
-
CopyOnWriteArrayIdentityList
public CopyOnWriteArrayIdentityList()
Creates a new, empty instance of CopyOnWriteArrayList.
-
CopyOnWriteArrayIdentityList
public CopyOnWriteArrayIdentityList(Collection<? extends E> c)
Creates a new instance of CopyOnWriteArrayList and fills it with the contents of a given Collection.- Parameters:
c- the collection the elements of which are to be copied into the new instance.
-
CopyOnWriteArrayIdentityList
public CopyOnWriteArrayIdentityList(E[] array)
Creates a new instance of CopyOnWriteArrayList and fills it with the contents of a given array.- Parameters:
array- the array the elements of which are to be copied into the new instance.
-
-
Method Detail
-
add
public boolean add(E e)
-
addAll
public boolean addAll(Collection<? extends E> c)
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
addAllAbsent
public int addAllAbsent(Collection<? extends E> c)
Adds to this CopyOnWriteArrayList all those elements from a given collection that are not yet part of the list.- Parameters:
c- the collection from which the potential new elements are taken.- Returns:
- the number of elements actually added to this list.
-
addIfAbsent
public boolean addIfAbsent(E e)
Adds to this CopyOnWriteArrayList another element, given that this element is not yet part of the list.- Parameters:
e- the potential new element.- Returns:
- true if the element was added, or false otherwise.
-
clear
public void clear()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
indexOf
public int indexOf(E e, int index)
Returns the index of a given element, starting the search from a given position in the list.- Parameters:
e- the element to search.index- the index at which to start the search.- Returns:
- the index of the element or null, if the element has not been found at or beyond the given start index.
-
isEmpty
public boolean isEmpty()
-
lastIndexOf
public int lastIndexOf(E e, int index)
Returns the last index of a given element, starting the search from a given position in the list and going backwards.- Parameters:
e- the element to search.index- the index at which to start the search.- Returns:
- the index of the element or null, if the element has not been found at or before the given start index.
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
size
public int size()
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
-