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>
ADeque
that 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 boolean
add(T t)
boolean
addAll(Collection<? extends T> c)
void
addFirst(T t)
void
addLast(T t)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
Iterator<T>
descendingIterator()
T
element()
boolean
equals(Object obj)
void
forEach(Consumer<? super T> action)
T
getFirst()
T
getLast()
int
hashCode()
boolean
isEmpty()
Iterator<T>
iterator()
long
modCount()
Gets the number of modifications made to the deque.Counter.LongCounter
modCounter()
Gets the counter that keeps track of the number of modifications made to the deque.boolean
offer(T t)
boolean
offerFirst(T t)
boolean
offerLast(T t)
Stream<T>
parallelStream()
T
peek()
T
peekFirst()
T
peekLast()
T
poll()
T
pollFirst()
T
pollLast()
T
pop()
void
push(T t)
T
remove()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
T
removeFirst()
boolean
removeFirstOccurrence(Object o)
boolean
removeIf(Predicate<? super T> filter)
T
removeLast()
boolean
removeLastOccurrence(Object o)
boolean
retainAll(Collection<?> c)
int
size()
Spliterator<T>
spliterator()
Stream<T>
stream()
Object[]
toArray()
<T1> T1[]
toArray(IntFunction<T1[]> generator)
<T1> T1[]
toArray(T1[] a)
String
toString()
static <V> ModCountDeque<V>
wrap(Deque<V> deque)
Wraps a set in aModCountDeque
that 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 aModCountDeque
that 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:
clear
in interfaceCollection<T>
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<T>
-
descendingIterator
public Iterator<T> descendingIterator()
- Specified by:
descendingIterator
in interfaceDeque<T>
-
element
public T element()
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in interfaceCollection<T>
- Overrides:
equals
in 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:
hashCode
in interfaceCollection<T>
- Overrides:
hashCode
in classObject
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<T>
-
offer
public boolean offer(T t)
-
offerFirst
public boolean offerFirst(T t)
- Specified by:
offerFirst
in interfaceDeque<T>
-
parallelStream
public Stream<T> parallelStream()
- Specified by:
parallelStream
in 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:
removeAll
in interfaceCollection<T>
-
removeFirst
public T removeFirst()
- Specified by:
removeFirst
in interfaceDeque<T>
-
removeFirstOccurrence
public boolean removeFirstOccurrence(Object o)
- Specified by:
removeFirstOccurrence
in interfaceDeque<T>
-
removeIf
public boolean removeIf(Predicate<? super T> filter)
- Specified by:
removeIf
in interfaceCollection<T>
-
removeLast
public T removeLast()
- Specified by:
removeLast
in interfaceDeque<T>
-
removeLastOccurrence
public boolean removeLastOccurrence(Object o)
- Specified by:
removeLastOccurrence
in interfaceDeque<T>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<T>
-
size
public int size()
-
spliterator
public Spliterator<T> spliterator()
- Specified by:
spliterator
in interfaceCollection<T>
- Specified by:
spliterator
in interfaceIterable<T>
-
stream
public Stream<T> stream()
- Specified by:
stream
in interfaceCollection<T>
-
toArray
public <T1> T1[] toArray(IntFunction<T1[]> generator)
- Specified by:
toArray
in interfaceCollection<T>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<T>
-
toArray
public <T1> T1[] toArray(T1[] a)
- Specified by:
toArray
in interfaceCollection<T>
-
wrap
public static <V> ModCountDeque<V> wrap(Deque<V> deque)
Wraps a set in aModCountDeque
that 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 aModCountDeque
that 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.
-
-