Class SparseSet

java.lang.Object
org.jacop.util.SparseSet

public class SparseSet extends Object
Sparse set representation of the set.
Version:
4.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int[]
    Dense array used within SparseSet functionality.
    int
    It specifies number of elements in the SparseSet.
    int[]
    Sparse array used within SparseSet functionality.
  • 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

    Modifier and Type
    Method
    Description
    boolean
    addMember(int value)
    It adds an element to the set.
    void
    It removes all the elements by setting the number of members to zero.
    boolean
    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.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • 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 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

      public String toString()
      Overrides:
      toString in class Object