Class 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 Detail

      • ComplementSet

        protected ComplementSet​(boolean isComplement,
                                java.util.Set<T> elements)
    • Method Detail

      • 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.
      • 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()
        toString in class java.lang.Object
      • isEmpty

        public boolean isEmpty()
      • clear

        public void clear()
      • contains

        public boolean contains​(T element)