public class SplittableElementSet<E extends Element> extends Object implements Comparator<E>, Serializable
Element
that can be split
into multiple sub-sets.
The partitioning is provided by an index that indicate, at instantiation, the right partition for each element.
The backend is a simple array of elements. Elements belonging to the same partition are contiguous for efficiency.
Constructor and Description |
---|
SplittableElementSet(E[] c,
gnu.trove.map.hash.TIntIntHashMap idx)
Make a new splittable set.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(E o1,
E o2) |
boolean |
forEachPartition(IterateProcedure<E> p)
Execute a procedure on each partition.
|
List<ElementSubSet<E>> |
getPartitions()
Get all the partitions as subsets.
|
gnu.trove.map.hash.TIntIntHashMap |
getRespectiveIndex()
Get the index associated to each element.
|
Set<E> |
getSubSet(int k)
Get a subset for the given partition.
|
E[] |
getValues()
Get the backend array of elements.
|
static SplittableElementSet<Node> |
newNodeIndex(Collection<Node> c,
gnu.trove.map.hash.TIntIntHashMap idx)
Make a new splittable set from a collection of nodes.
|
static SplittableElementSet<VM> |
newVMIndex(Collection<VM> c,
gnu.trove.map.hash.TIntIntHashMap idx)
Make a new splittable set from a collection of VM.
|
int |
size()
Get the size of the set.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public SplittableElementSet(E[] c, gnu.trove.map.hash.TIntIntHashMap idx)
c
- the elements, no duplicates are supposedidx
- the partition associated to each element. Format Element.id()
-> keypublic static SplittableElementSet<VM> newVMIndex(Collection<VM> c, gnu.trove.map.hash.TIntIntHashMap idx)
c
- the collection to wrapidx
- the partition for each VMpublic static SplittableElementSet<Node> newNodeIndex(Collection<Node> c, gnu.trove.map.hash.TIntIntHashMap idx)
c
- the collection to wrapidx
- the partition for each nodepublic boolean forEachPartition(IterateProcedure<E> p)
p
- the procedure to executepublic Set<E> getSubSet(int k)
k
- the partition keypublic int compare(E o1, E o2)
compare
in interface Comparator<E extends Element>
public gnu.trove.map.hash.TIntIntHashMap getRespectiveIndex()
Element.id()
-> index valuepublic E[] getValues()
public List<ElementSubSet<E>> getPartitions()
ElementSubSet
.public int size()
Copyright © 2015 University of Nice-Sophia Antipolis. All Rights Reserved.