Class BitExternalSet<T>

  • Type Parameters:
    T - the type of elements inside this set
    All Implemented Interfaces:
    ExternalSet<T>, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Set<T>

    public final class BitExternalSet<T>
    extends java.lang.Object
    implements ExternalSet<T>
    An ExternalSet where the indexes of the elements included in the set are stored through bit vectors, enabling better memory efficiency.
    • Method Detail

      • add

        public boolean add​(T e)
        Specified by:
        add in interface java.util.Collection<T>
        Specified by:
        add in interface java.util.Set<T>
      • addAll

        public void addAll​(ExternalSet<T> other)
        Description copied from interface: ExternalSet
        Adds to this set all elements contained into other. This method is faster than Set.addAll(Collection) since it directly operates on the underlying bit set.
        Specified by:
        addAll in interface ExternalSet<T>
        Parameters:
        other - the other set
      • remove

        public boolean remove​(java.lang.Object e)
        Specified by:
        remove in interface java.util.Collection<T>
        Specified by:
        remove in interface java.util.Set<T>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<T>
        Specified by:
        size in interface java.util.Set<T>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<T>
        Specified by:
        isEmpty in interface java.util.Set<T>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface java.util.Set<T>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<T>
        Specified by:
        hashCode in interface java.util.Set<T>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<T>
        Specified by:
        equals in interface java.util.Set<T>
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T>
        Specified by:
        clear in interface java.util.Set<T>
      • copy

        public BitExternalSet<T> copy()
        Description copied from interface: ExternalSet
        Yields a fresh copy of this set, defined over the same cache and containing the same elements.
        Specified by:
        copy in interface ExternalSet<T>
        Returns:
        the fresh copy
      • contains

        public boolean contains​(ExternalSet<T> other)
        Description copied from interface: ExternalSet
        Determines if this set contains all elements of another if they share the same cache. This method is faster than Set.containsAll(Collection) since it directly operates on the underlying bit set.
        Specified by:
        contains in interface ExternalSet<T>
        Parameters:
        other - the other set
        Returns:
        true if and only if other is included into this set
      • intersects

        public boolean intersects​(ExternalSet<T> other)
        Description copied from interface: ExternalSet
        Determines if this set has at least an element in common with another if they share the same cache.
        Specified by:
        intersects in interface ExternalSet<T>
        Parameters:
        other - the other set
        Returns:
        true if and only if this set intersects the other
      • intersection

        public ExternalSet<T> intersection​(ExternalSet<T> other)
        Description copied from interface: ExternalSet
        Yields the intersection of this set and another. Neither of them gets modified. If other is null, or if the two sets are not defined over the same cache, this set is returned.
        Specified by:
        intersection in interface ExternalSet<T>
        Parameters:
        other - the other set
        Returns:
        the intersection of the two sets
      • difference

        public ExternalSet<T> difference​(ExternalSet<T> other)
        Description copied from interface: ExternalSet
        Yields a new set obtained from this by removing the given elements. If other is null, or if the two sets are not defined over the same cache, this set is returned.
        Specified by:
        difference in interface ExternalSet<T>
        Parameters:
        other - the elements to remove
        Returns:
        a set obtained from this by removing the elements in other
      • union

        public ExternalSet<T> union​(ExternalSet<T> other)
        Description copied from interface: ExternalSet
        Yields the union of this set and another. Neither of them gets modified. If other is null, or if the two sets are not defined over the same cache, this set is returned.
        Specified by:
        union in interface ExternalSet<T>
        Parameters:
        other - the other set
        Returns:
        the union of this set and other
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<T>
        Specified by:
        contains in interface java.util.Set<T>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<T>
        Specified by:
        toArray in interface java.util.Set<T>
      • toArray

        public <E> E[] toArray​(E[] a)
        Specified by:
        toArray in interface java.util.Collection<T>
        Specified by:
        toArray in interface java.util.Set<T>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<T>
        Specified by:
        containsAll in interface java.util.Set<T>
      • addAll

        public boolean addAll​(java.util.Collection<? extends T> c)
        Specified by:
        addAll in interface java.util.Collection<T>
        Specified by:
        addAll in interface java.util.Set<T>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<T>
        Specified by:
        retainAll in interface java.util.Set<T>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<T>
        Specified by:
        removeAll in interface java.util.Set<T>