Package org.jacop.util
Class SparseSet
java.lang.Object
org.jacop.util.SparseSet
Sparse set representation of the set.
- Version:
- 4.9
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSparseSet
(int size) It creates a SparseSet with given upper limit on the value of the biggest element in the set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addMember
(int value) It adds an element to the set.void
clear()
It removes all the elements by setting the number of members to zero.boolean
isEmpty()
It returns true if the set is empty.boolean
isMember
(int k) It checks if the specified element belongs to the set.void
setSize
(int size) It sets the size of the SparseSet.toString()
-
Field Details
-
sparse
public int[] sparseSparse array used within SparseSet functionality. -
dense
public int[] denseDense array used within SparseSet functionality. -
members
public int membersIt specifies number of elements in the SparseSet.
-
-
Constructor Details
-
SparseSet
public SparseSet(int size) It creates a SparseSet with given upper limit on the value of the biggest element in the set.- Parameters:
size
- the upper limit for the SparseSet
-
-
Method Details
-
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
-