Package de.xima.fc.common.collection
Class ModCountDeque<T>
- java.lang.Object
-
- de.xima.fc.common.collection.ModCountDeque<T>
-
- Type Parameters:
T- The type of elements in the deque.
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Deque<T>,Queue<T>
public final class ModCountDeque<T> extends Object implements Deque<T>
ADequethat keeps track of the number of modifications made to it. The only guarantee is that the modification increases by some amount when the deque is modified. No guarantees are made about the exact amount by which the modification counter increases. This class is not thread-safe.- Since:
- 8.2.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T t)booleanaddAll(Collection<? extends T> c)voidaddFirst(T t)voidaddLast(T t)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)Iterator<T>descendingIterator()Telement()booleanequals(Object obj)voidforEach(Consumer<? super T> action)TgetFirst()TgetLast()inthashCode()booleanisEmpty()Iterator<T>iterator()longmodCount()Gets the number of modifications made to the deque.Counter.LongCountermodCounter()Gets the counter that keeps track of the number of modifications made to the deque.booleanoffer(T t)booleanofferFirst(T t)booleanofferLast(T t)Stream<T>parallelStream()Tpeek()TpeekFirst()TpeekLast()Tpoll()TpollFirst()TpollLast()Tpop()voidpush(T t)Tremove()booleanremove(Object o)booleanremoveAll(Collection<?> c)TremoveFirst()booleanremoveFirstOccurrence(Object o)booleanremoveIf(Predicate<? super T> filter)TremoveLast()booleanremoveLastOccurrence(Object o)booleanretainAll(Collection<?> c)intsize()Spliterator<T>spliterator()Stream<T>stream()Object[]toArray()<T1> T1[]toArray(IntFunction<T1[]> generator)<T1> T1[]toArray(T1[] a)StringtoString()static <V> ModCountDeque<V>wrap(Deque<V> deque)Wraps a set in aModCountDequethat keeps track of the number of modifications made to it.static <V> ModCountDeque<V>wrap(Deque<V> set, Counter.LongCounter modCounter)Wraps a deque in aModCountDequethat keeps track of the number of modifications made to it.
-
-
-
Method Detail
-
add
public boolean add(T t)
-
addAll
public boolean addAll(Collection<? extends T> c)
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T>
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T>
-
descendingIterator
public Iterator<T> descendingIterator()
- Specified by:
descendingIteratorin interfaceDeque<T>
-
element
public T element()
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin interfaceCollection<T>- Overrides:
equalsin classObject
-
modCount
public long modCount()
Gets the number of modifications made to the deque.- Returns:
- The number of modifications made to the deque.
-
modCounter
public Counter.LongCounter modCounter()
Gets the counter that keeps track of the number of modifications made to the deque.- Returns:
- The counter that keeps track of the number of modifications made to the deque.
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<T>- Overrides:
hashCodein classObject
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T>
-
offer
public boolean offer(T t)
-
offerFirst
public boolean offerFirst(T t)
- Specified by:
offerFirstin interfaceDeque<T>
-
parallelStream
public Stream<T> parallelStream()
- Specified by:
parallelStreamin interfaceCollection<T>
-
peek
public T peek()
-
poll
public T poll()
-
remove
public T remove()
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<T>
-
removeFirst
public T removeFirst()
- Specified by:
removeFirstin interfaceDeque<T>
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Object o)
- Specified by:
removeFirstOccurrencein interfaceDeque<T>
-
removeIf
public boolean removeIf(Predicate<? super T> filter)
- Specified by:
removeIfin interfaceCollection<T>
-
removeLast
public T removeLast()
- Specified by:
removeLastin interfaceDeque<T>
-
removeLastOccurrence
public boolean removeLastOccurrence(Object o)
- Specified by:
removeLastOccurrencein interfaceDeque<T>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<T>
-
size
public int size()
-
spliterator
public Spliterator<T> spliterator()
- Specified by:
spliteratorin interfaceCollection<T>- Specified by:
spliteratorin interfaceIterable<T>
-
stream
public Stream<T> stream()
- Specified by:
streamin interfaceCollection<T>
-
toArray
public <T1> T1[] toArray(IntFunction<T1[]> generator)
- Specified by:
toArrayin interfaceCollection<T>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T>
-
toArray
public <T1> T1[] toArray(T1[] a)
- Specified by:
toArrayin interfaceCollection<T>
-
wrap
public static <V> ModCountDeque<V> wrap(Deque<V> deque)
Wraps a set in aModCountDequethat keeps track of the number of modifications made to it. May not wrap if already wrapped.- Type Parameters:
V- Value type.- Parameters:
deque- The set to wrap.- Returns:
- The wrapped set.
-
wrap
public static <V> ModCountDeque<V> wrap(Deque<V> set, Counter.LongCounter modCounter)
Wraps a deque in aModCountDequethat keeps track of the number of modifications made to it. May not wrap if already wrapped in a ModCountDeque with the same modCounter.- Type Parameters:
V- Value type.- Parameters:
set- The deque to wrap.modCounter- The modification counter to use.- Returns:
- The wrapped deque.
-
-