Class SortedCopyOnWriteArray<T extends Comparable<T>>
java.lang.Object
com.comphenix.protocol.concurrency.SortedCopyOnWriteArray<T>
- Type Parameters:
T- - type of the elements in the list.
- All Implemented Interfaces:
Iterable<T>,Collection<T>
public class SortedCopyOnWriteArray<T extends Comparable<T>>
extends Object
implements Collection<T>
An implicitly sorted array list that preserves insertion order and maintains duplicates.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty sorted array.SortedCopyOnWriteArray(Collection<T> wrapped) Create a sorted array from the given list. -
Method Summary
Modifier and TypeMethodDescriptionbooleanInserts the given element in the proper location.booleanaddAll(Collection<? extends T> values) voidclear()booleanbooleancontainsAll(Collection<?> values) get(int index) Retrieves an element by index.booleanisEmpty()iterator()Retrieves an iterator over the elements in the given list.voidremove(int index) Removes from the list by making a copy of every element except the one with the given index.booleanRemoves from the list by making a new list with every element except the one given.booleanremoveAll(Collection<?> values) booleanretainAll(Collection<?> values) intsize()Retrieve the size of the list.Object[]toArray()<T> T[]toArray(T[] a) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
SortedCopyOnWriteArray
public SortedCopyOnWriteArray()Construct an empty sorted array. -
SortedCopyOnWriteArray
Create a sorted array from the given list. The elements will be automatically sorted.- Parameters:
wrapped- - the collection whose elements are to be placed into the list.
-
-
Method Details
-
add
Inserts the given element in the proper location.- Specified by:
addin interfaceCollection<T extends Comparable<T>>- Parameters:
value- - element to insert.
-
addAll
- Specified by:
addAllin interfaceCollection<T extends Comparable<T>>
-
remove
Removes from the list by making a new list with every element except the one given.Objects will be compared using the given objects equals() method.
- Specified by:
removein interfaceCollection<T extends Comparable<T>>- Parameters:
value- - value to remove.
-
removeAll
- Specified by:
removeAllin interfaceCollection<T extends Comparable<T>>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T extends Comparable<T>>
-
remove
public void remove(int index) Removes from the list by making a copy of every element except the one with the given index.- Parameters:
index- - index of the element to remove.
-
get
Retrieves an element by index.- Parameters:
index- - index of element to retrieve.- Returns:
- The element at the given location.
-
size
public int size()Retrieve the size of the list.- Specified by:
sizein interfaceCollection<T extends Comparable<T>>- Returns:
- Size of the list.
-
iterator
Retrieves an iterator over the elements in the given list. Warning: No not attempt to remove elements using the iterator.- Specified by:
iteratorin interfaceCollection<T extends Comparable<T>>- Specified by:
iteratorin interfaceIterable<T extends Comparable<T>>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T extends Comparable<T>>
-
contains
- Specified by:
containsin interfaceCollection<T extends Comparable<T>>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T extends Comparable<T>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T extends Comparable<T>>
-
toArray
- Specified by:
toArrayin interfaceCollection<T extends Comparable<T>>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<T extends Comparable<T>>
-
toString
-