public class SparseSet extends Object
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
SparseSet(int size)
It creates a SparseSet with given upper limit on the value
of the biggest element in the set.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
toString() |
public int[] sparse
public int[] dense
public int members
public SparseSet(int size)
size
- the upper limit for the SparseSetpublic boolean isMember(int k)
k
- element for which the membership in the given set is checked.public boolean addMember(int value)
value
- value being added.public void setSize(int size)
size
- the assigned size of the set.public boolean isEmpty()
public void clear()
Copyright © 2022. All rights reserved.