public class IntegerSet
extends java.lang.Object
This class implements a set of integers and its basic operations
Constructor and Description |
---|
IntegerSet()
Constructor without parameters
|
IntegerSet(int _maxsize)
Constructor with initial size
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(int elem)
It adds a value to the set if it is not present
|
int |
getElement(int i)
It returns the element at position i
|
boolean |
presence(int e)
It returns true if the element e is present in the set
|
void |
print()
It prints the set
|
void |
removeValue(int elem)
It removes a value of the set if it is present
|
int |
size()
It returns the size of the set
|
public IntegerSet()
Constructor without parameters
public IntegerSet(int _maxsize)
Constructor with initial size
_maxsize
- initial size of the set.public void addValue(int elem)
It adds a value to the set if it is not present
elem
- the new value to add
public void removeValue(int elem)
It removes a value of the set if it is present
elem
- the vale to remove
public int size()
It returns the size of the set
public int getElement(int i)
It returns the element at position i
i
- the positionpublic void print()
It prints the set
public boolean presence(int e)
It returns true if the element e is present in the set
e
- the value to find