Package org.jacop.util
Class SparseSet
- java.lang.Object
-
- org.jacop.util.SparseSet
-
public class SparseSet extends java.lang.ObjectSparse set representation of the set.- Version:
- 4.8
-
-
Constructor Summary
Constructors Constructor Description SparseSet(int size)It creates a SparseSet with given upper limit on the value of the biggest element in the set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddMember(int value)It adds an element to the set.voidclear()It removes all the elements by setting the number of members to zero.booleanisEmpty()It returns true if the set is empty.booleanisMember(int k)It checks if the specified element belongs to the set.voidsetSize(int size)It sets the size of the SparseSet.java.lang.StringtoString()
-
-
-
Method Detail
-
isMember
public boolean isMember(int k)
It checks if the specified element belongs to the set.- Parameters:
k- element for which the membership in the given set is checked.- Returns:
- true if k belongs to the sparse set, false otherwise.
-
addMember
public boolean addMember(int value)
It adds an element to the set.- Parameters:
value- value being added.- Returns:
- true if the value was not present before and was added to the set, false otherwise.
-
setSize
public void setSize(int size)
It sets the size of the SparseSet.- Parameters:
size- the assigned size of the set.
-
isEmpty
public boolean isEmpty()
It returns true if the set is empty.- Returns:
- true if the set is empty, false otherwise.
-
clear
public void clear()
It removes all the elements by setting the number of members to zero.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-