Package com.ibm.wala.util.intset
Class OrdinalSet<T>
- java.lang.Object
-
- com.ibm.wala.util.intset.OrdinalSet<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>
public class OrdinalSet<T> extends java.lang.Object implements java.lang.Iterable<T>
A Set backed by a set of integers.
-
-
Constructor Summary
Constructors Constructor Description OrdinalSet(IntSet S, OrdinalSetMapping<T> mapping)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(T object)
boolean
containsAny(OrdinalSet<T> that)
static <T> OrdinalSet<T>
empty()
static <T> boolean
equals(OrdinalSet<T> a, OrdinalSet<T> b)
IntSet
getBackingSet()
Dangerous.OrdinalSetMapping<T>
getMapping()
static <T> OrdinalSet<T>
intersect(OrdinalSet<T> A, OrdinalSet<T> B)
boolean
isEmpty()
java.util.Iterator<T>
iterator()
SparseIntSet
makeSparseCopy()
int
size()
static <T> java.util.Collection<T>
toCollection(OrdinalSet<T> instances)
static <T> OrdinalSet<T>
toOrdinalSet(java.util.Collection<T> c, OrdinalSetMapping<T> m)
Precondition: the ordinal set mapping has an index for every element of c Convert a "normal" collection to an OrdinalSet, based on the given mapping.java.lang.String
toString()
static <T> OrdinalSet<T>
unify(OrdinalSet<T> A, OrdinalSet<T> B)
Creates the union of two ordinal sets.
-
-
-
Constructor Detail
-
OrdinalSet
public OrdinalSet(IntSet S, OrdinalSetMapping<T> mapping)
-
-
Method Detail
-
empty
public static <T> OrdinalSet<T> empty()
-
containsAny
public boolean containsAny(OrdinalSet<T> that)
-
size
public int size()
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
intersect
public static <T> OrdinalSet<T> intersect(OrdinalSet<T> A, OrdinalSet<T> B)
- Returns:
- a new OrdinalSet instances
- Throws:
java.lang.IllegalArgumentException
- if A is null
-
equals
public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b)
- Returns:
- true if the contents of two sets are equal
-
unify
public static <T> OrdinalSet<T> unify(OrdinalSet<T> A, OrdinalSet<T> B)
Creates the union of two ordinal sets.- Parameters:
A
- ordinal set aB
- ordinal set b- Returns:
- union of a and b
- Throws:
java.lang.IllegalArgumentException
- iff A or B is null
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
makeSparseCopy
public SparseIntSet makeSparseCopy()
-
getBackingSet
public IntSet getBackingSet()
Dangerous. Added for performance reasons. Use this only if you really know what you are doing.
-
contains
public boolean contains(T object)
- Returns:
- true iff this set contains object
-
isEmpty
public boolean isEmpty()
-
toCollection
public static <T> java.util.Collection<T> toCollection(OrdinalSet<T> instances)
- Throws:
java.lang.NullPointerException
- if instances is null
-
toOrdinalSet
public static <T> OrdinalSet<T> toOrdinalSet(java.util.Collection<T> c, OrdinalSetMapping<T> m)
Precondition: the ordinal set mapping has an index for every element of c Convert a "normal" collection to an OrdinalSet, based on the given mapping.- Throws:
java.lang.IllegalArgumentException
- if c is null
-
getMapping
public OrdinalSetMapping<T> getMapping()
-
-