JaCoP.util
Class SparseSet

java.lang.Object
  extended by JaCoP.util.SparseSet

public class SparseSet
extends java.lang.Object

Sparse set representation of the set.

Version:
3.1
Author:
Radoslaw Szymanek and Krzysztof Kuchcinski

Field Summary
 int[] dense
          Dense array used within SparseSet functionality.
 int members
          It specifies number of elements in the SparseSet.
 int[] sparse
          Sparse array used within SparseSet functionality.
 
Constructor Summary
SparseSet(int size)
          It creates a SparseSet with given upper limit on the value of the biggest element in the set.
 
Method Summary
 boolean 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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sparse

public int[] sparse
Sparse array used within SparseSet functionality.


dense

public int[] dense
Dense array used within SparseSet functionality.


members

public int members
It specifies number of elements in the SparseSet.

Constructor Detail

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 -
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:
toString in class java.lang.Object