Class AttachmentList<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,RandomAccess
List meant for use with an Attachable object. The list has concurrency semantics equivalent to
Collections.synchronizedList; i.e. it is thread safe for reads and writes not involving an iterator or stream
but if reads can occur concurrently with writes it is imperative that the user manually synchronize on the list
when iterating over it:
AttachmentListlist = new AttachmentList<>()</>; ... synchronized (list) { Iterator i = list.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }
- Author:
- David M. Lloyd
-
Constructor Summary
ConstructorsConstructorDescriptionAttachmentList(int initialCapacity, Class<E> valueClass) Creates a newAttachmentList.AttachmentList(Class<E> valueClass) Creates a newAttachmentList.AttachmentList(Collection<? extends E> c, Class<E> valueClass) Creates a newAttachmentList. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidclear()booleanbooleancontainsAll(Collection<?> c) booleanvoidget(int index) inthashCode()intbooleanisEmpty()iterator()intlistIterator(int index) remove(int index) booleanbooleanremoveAll(Collection<?> c) booleanvoidreplaceAll(UnaryOperator<E> operator) booleanretainAll(Collection<?> c) intsize()voidsort(Comparator<? super E> c) stream()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
toArray
-
Constructor Details
-
AttachmentList
Creates a newAttachmentList.- Parameters:
initialCapacity- the initial capacity of the listvalueClass- the type of element the list is permitted to hold
-
AttachmentList
Creates a newAttachmentList.- Parameters:
valueClass- the type of element the list is permitted to hold
-
AttachmentList
Creates a newAttachmentList.- Parameters:
c- initial contents of the list. Cannot benullvalueClass- the type of element the list is permitted to hold
-
-
Method Details
-
getValueClass
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it.
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
add
-
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
addAll
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
equals
-
hashCode
public int hashCode() -
get
-
set
-
add
-
remove
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it.
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when iterating over it.
- Specified by:
listIteratorin interfaceList<E>
-
subList
-
forEach
-
removeIf
- Specified by:
removeIfin interfaceCollection<E>
-
replaceAll
- Specified by:
replaceAllin interfaceList<E>
-
sort
-
spliterator
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when using the
Spliterator.- Specified by:
spliteratorin interfaceCollection<E>- Specified by:
spliteratorin interfaceIterable<E>- Specified by:
spliteratorin interfaceList<E>
-
stream
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when using the
Stream.- Specified by:
streamin interfaceCollection<E>
-
parallelStream
If reads can occur concurrently with writes it is imperative that the user manually synchronize on the list when using the
Stream.- Specified by:
parallelStreamin interfaceCollection<E>
-