Package de.xima.fc.common.collection
Class ModCountSet<V>
- java.lang.Object
-
- de.xima.fc.common.collection.ModCountSet<V>
-
- Type Parameters:
V
- Type of the elements in the set.
- All Implemented Interfaces:
Iterable<V>
,Collection<V>
,Set<V>
public final class ModCountSet<V> extends Object implements Set<V>
A set 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(V v)
boolean
addAll(Collection<? extends V> c)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
boolean
equals(Object obj)
void
forEach(Consumer<? super V> action)
int
hashCode()
boolean
isEmpty()
Iterator<V>
iterator()
long
modCount()
Gets the number of modifications made to this set.Counter.LongCounter
modCounter()
Gets the modification counter.Stream<V>
parallelStream()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
removeIf(Predicate<? super V> filter)
boolean
retainAll(Collection<?> c)
int
size()
Spliterator<V>
spliterator()
Stream<V>
stream()
Object[]
toArray()
<T> T[]
toArray(IntFunction<T[]> generator)
<T> T[]
toArray(T[] a)
String
toString()
static <V> ModCountSet<V>
wrap(Set<V> set)
Wraps a set in aModCountSet
that keeps track of the number of modifications made to it.static <V> ModCountSet<V>
wrap(Set<V> set, Counter.LongCounter modCounter)
Wraps a set in aModCountSet
that keeps track of the number of modifications made to it.
-
-
-
Method Detail
-
add
public boolean add(V v)
-
addAll
public boolean addAll(Collection<? extends V> c)
-
clear
public void clear()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<V>
- Specified by:
containsAll
in interfaceSet<V>
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
isEmpty
public boolean isEmpty()
-
modCount
public long modCount()
Gets the number of modifications made to this set.- Returns:
- The number of modifications made to this set.
-
modCounter
public Counter.LongCounter modCounter()
Gets the modification counter.- Returns:
- The modification counter.
-
parallelStream
public Stream<V> parallelStream()
- Specified by:
parallelStream
in interfaceCollection<V>
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection<?> c)
-
removeIf
public boolean removeIf(Predicate<? super V> filter)
- Specified by:
removeIf
in interfaceCollection<V>
-
retainAll
public boolean retainAll(Collection<?> c)
-
size
public int size()
-
spliterator
public Spliterator<V> spliterator()
- Specified by:
spliterator
in interfaceCollection<V>
- Specified by:
spliterator
in interfaceIterable<V>
- Specified by:
spliterator
in interfaceSet<V>
-
stream
public Stream<V> stream()
- Specified by:
stream
in interfaceCollection<V>
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
toArray
public <T> T[] toArray(IntFunction<T[]> generator)
- Specified by:
toArray
in interfaceCollection<V>
-
wrap
public static <V> ModCountSet<V> wrap(Set<V> set)
Wraps a set in aModCountSet
that keeps track of the number of modifications made to it. May not wrap if already wrapped.- Type Parameters:
V
- Value type.- Parameters:
set
- The set to wrap.- Returns:
- The wrapped set.
-
wrap
public static <V> ModCountSet<V> wrap(Set<V> set, Counter.LongCounter modCounter)
Wraps a set in aModCountSet
that keeps track of the number of modifications made to it. May not wrap if already wrapped in a ModCountSet with the same modCounter.- Type Parameters:
V
- Value type.- Parameters:
set
- The set to wrap.modCounter
- The modification counter to use.- Returns:
- The wrapped set.
-
-