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>
AnExternalSet
where 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 boolean
add(T e)
void
addAll(ExternalSet<T> other)
Adds to this set all elements contained intoother
.boolean
addAll(java.util.Collection<? extends T> c)
void
clear()
boolean
contains(ExternalSet<T> other)
Determines if this set contains all elements of another if they share the same cache.boolean
contains(java.lang.Object o)
boolean
containsAll(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.boolean
equals(java.lang.Object obj)
ExternalSetCache<T>
getCache()
Yields the cache that this set is connected to.int
hashCode()
ExternalSet<T>
intersection(ExternalSet<T> other)
Yields the intersection of this set and another.boolean
intersects(ExternalSet<T> other)
Determines if this set has at least an element in common with another if they share the same cache.boolean
isEmpty()
java.util.Iterator<T>
iterator()
boolean
remove(java.lang.Object e)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
int
size()
java.lang.Object[]
toArray()
<E> E[]
toArray(E[] a)
java.lang.String
toString()
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:ExternalSet
Yields the cache that this set is connected to.- Specified by:
getCache
in interfaceExternalSet<T>
- Returns:
- the cache
-
add
public boolean add(T e)
-
addAll
public void addAll(ExternalSet<T> other)
Description copied from interface:ExternalSet
Adds 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:
addAll
in 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:
toString
in classjava.lang.Object
-
clear
public void clear()
-
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 interfaceExternalSet<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 thanSet.containsAll(Collection)
since it directly operates on the underlying bit set.- Specified by:
contains
in interfaceExternalSet<T>
- Parameters:
other
- the other set- Returns:
true
if and only ifother
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 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:ExternalSet
Yields the intersection of this set and another. Neither of them gets modified. Ifother
isnull
, or if the two sets are not defined over the same cache, this set is returned.- Specified by:
intersection
in 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:ExternalSet
Yields a new set obtained from this by removing the given elements. Ifother
isnull
, or if the two sets are not defined over the same cache, this set is returned.- Specified by:
difference
in 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:ExternalSet
Yields the union of this set and another. Neither of them gets modified. Ifother
isnull
, or if the two sets are not defined over the same cache, this set is returned.- Specified by:
union
in 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)
-
-