Class BitExternalSet<T>
- java.lang.Object
-
- it.unive.lisa.util.collections.externalSet.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>
AnExternalSetwhere the indexes of the elements included in the set are stored through bit vectors, enabling better memory efficiency.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T e)voidaddAll(ExternalSet<T> other)Adds to this set all elements contained intoother.booleanaddAll(java.util.Collection<? extends T> c)voidclear()booleancontains(ExternalSet<T> other)Determines if this set contains all elements of another if they share the same cache.booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)BitExternalSet<T>copy()Yields a fresh copy of this set, defined over the same cache and containing the same elements.ExternalSet<T>difference(ExternalSet<T> other)Yields a new set obtained from this by removing the given elements.booleanequals(java.lang.Object obj)ExternalSetCache<T>getCache()Yields the cache that this set is connected to.inthashCode()ExternalSet<T>intersection(ExternalSet<T> other)Yields the intersection of this set and another.booleanintersects(ExternalSet<T> other)Determines if this set has at least an element in common with another if they share the same cache.booleanisEmpty()java.util.Iterator<T>iterator()booleanremove(java.lang.Object e)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)intsize()java.lang.Object[]toArray()<E> E[]toArray(E[] a)java.lang.StringtoString()ExternalSet<T>union(ExternalSet<T> other)Yields the union of this set and another.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.util.collections.externalSet.ExternalSet
allMatch, anyMatch, collect, filter, first, multiTransform, noneMatch, reduce, transform
-
-
-
-
Method Detail
-
getCache
public ExternalSetCache<T> getCache()
Description copied from interface:ExternalSetYields the cache that this set is connected to.- Specified by:
getCachein interfaceExternalSet<T>- Returns:
- the cache
-
add
public boolean add(T e)
-
addAll
public void addAll(ExternalSet<T> other)
Description copied from interface:ExternalSetAdds to this set all elements contained intoother. This method is faster thanSet.addAll(Collection)since it directly operates on the underlying bit set.- Specified by:
addAllin interfaceExternalSet<T>- Parameters:
other- the other set
-
remove
public boolean remove(java.lang.Object e)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<T> iterator()
-
hashCode
public int hashCode()
-
equals
public boolean equals(java.lang.Object obj)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clear
public void clear()
-
copy
public BitExternalSet<T> copy()
Description copied from interface:ExternalSetYields a fresh copy of this set, defined over the same cache and containing the same elements.- Specified by:
copyin interfaceExternalSet<T>- Returns:
- the fresh copy
-
contains
public boolean contains(ExternalSet<T> other)
Description copied from interface:ExternalSetDetermines if this set contains all elements of another if they share the same cache. This method is faster thanSet.containsAll(Collection)since it directly operates on the underlying bit set.- Specified by:
containsin interfaceExternalSet<T>- Parameters:
other- the other set- Returns:
trueif and only ifotheris included into this set
-
intersects
public boolean intersects(ExternalSet<T> other)
Description copied from interface:ExternalSetDetermines if this set has at least an element in common with another if they share the same cache.- Specified by:
intersectsin interfaceExternalSet<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:ExternalSetYields the intersection of this set and another. Neither of them gets modified. Ifotherisnull, or if the two sets are not defined over the same cache, this set is returned.- Specified by:
intersectionin interfaceExternalSet<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:ExternalSetYields a new set obtained from this by removing the given elements. Ifotherisnull, or if the two sets are not defined over the same cache, this set is returned.- Specified by:
differencein interfaceExternalSet<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:ExternalSetYields the union of this set and another. Neither of them gets modified. Ifotherisnull, or if the two sets are not defined over the same cache, this set is returned.- Specified by:
unionin interfaceExternalSet<T>- Parameters:
other- the other set- Returns:
- the union of this set and
other
-
contains
public boolean contains(java.lang.Object o)
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <E> E[] toArray(E[] a)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
addAll
public boolean addAll(java.util.Collection<? extends T> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
-