Package com.linkedin.venice.utils
Class ComplementSet<T>
- java.lang.Object
-
- com.linkedin.venice.utils.ComplementSet<T>
-
public class ComplementSet<T> extends java.lang.Object
A set that uses complement representation, which is useful when universal set cardinality is unknown. If "isComplement" is set to false, the ComplementSet is the same as a regular Set; if "isComplement" is set to true, the "elements" inside ComplementSet represents the elements that the Set doesn't have.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ComplementSet(boolean isComplement, java.util.Set<T> elements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAll(ComplementSet<T> other)
void
clear()
boolean
contains(T element)
static <T> ComplementSet<T>
emptySet()
boolean
isEmpty()
static <T> ComplementSet<T>
newSet(ComplementSet<T> other)
static <T> ComplementSet<T>
newSet(java.util.Collection<T> elements)
This API will result in copying the data set, which is not performant or GC friendly if it's in critical path.static <T> ComplementSet<T>
of(T... elements)
void
removeAll(ComplementSet<T> other)
java.lang.String
toString()
static <T> ComplementSet<T>
universalSet()
Returns a set that contains all possible elements and is represented as a complement of an empty set.static <T> ComplementSet<T>
wrap(java.util.Set<T> elements)
This API will reuse the input "elements" which cannot be unmodifiable.
-
-
-
Constructor Detail
-
ComplementSet
protected ComplementSet(boolean isComplement, java.util.Set<T> elements)
-
-
Method Detail
-
of
public static <T> ComplementSet<T> of(T... elements)
-
wrap
public static <T> ComplementSet<T> wrap(java.util.Set<T> elements)
This API will reuse the input "elements" which cannot be unmodifiable.
-
newSet
public static <T> ComplementSet<T> newSet(java.util.Collection<T> elements)
This API will result in copying the data set, which is not performant or GC friendly if it's in critical path.
-
newSet
public static <T> ComplementSet<T> newSet(ComplementSet<T> other)
-
emptySet
public static <T> ComplementSet<T> emptySet()
-
universalSet
public static <T> ComplementSet<T> universalSet()
Returns a set that contains all possible elements and is represented as a complement of an empty set.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isEmpty
public boolean isEmpty()
-
clear
public void clear()
-
contains
public boolean contains(T element)
-
addAll
public void addAll(ComplementSet<T> other)
-
removeAll
public void removeAll(ComplementSet<T> other)
-
-