public class Set_LinkedList extends Object implements ISet
Modifier and Type | Field and Description |
---|---|
protected IntCell |
first
The first cell of the linked list
|
protected IntCell |
last |
protected IntCell |
nextCell |
protected IntCell |
poolGC |
protected int |
size |
Constructor and Description |
---|
Set_LinkedList() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(int element)
Add element to the set
Does not guaranty there is no duplications
|
void |
clear()
Remove all elements from the set
|
boolean |
contain(int element)
Test the existence of element in the set
|
int |
getFirstElement() |
int |
getMaxSize()
Gets the maximum size of the set, or -1 if it is unbounded.
|
int |
getNextElement()
enables to iterate over the set
should be used as follow :
for(int i=getFirstElement(); i>=0; i = getNextElement()){
...
}
The use of getFirstElement() is necessary to ensure a complete iteration
WARNING cannot encapsulate two for loops (copy the set for that)
|
SetType |
getSetType() |
int |
getSize() |
boolean |
isEmpty() |
boolean |
remove(int element)
Remove the first occurence of element from the set
|
int[] |
toArray()
Copies the set in an array if integers
|
String |
toString() |
protected IntCell first
protected IntCell last
protected int size
protected IntCell nextCell
protected IntCell poolGC
public boolean isEmpty()
public int getSize()
public boolean contain(int element)
ISet
public boolean add(int element)
ISet
public boolean remove(int element)
ISet
public void clear()
ISet
public int getFirstElement()
getFirstElement
in interface ISet
public int getNextElement()
ISet
getNextElement
in interface ISet
public SetType getSetType()
getSetType
in interface ISet
public int[] toArray()
ISet
public int getMaxSize()
ISet
getMaxSize
in interface ISet
Copyright © 2015. All rights reserved.