T
- public class AtomsAvlTree<T extends java.lang.Comparable<T>> extends java.lang.Object implements IAtomsCollection<T>
Modifier and Type | Field and Description |
---|---|
private int |
occupied
How much is the occupancy of the tree.
|
private byte |
process
Adsorption, desorption, reaction or diffusion.
|
private AvlTree |
tree
Actual AvlTree.
|
Constructor and Description |
---|
AtomsAvlTree(byte process,
AvlTree tree) |
Modifier and Type | Method and Description |
---|---|
private void |
addRate(Node<T> n,
T data) |
void |
addRate(T data)
Rate of current atom is added in the tree.
|
void |
clear()
Used to recompute the tree/total rate.
|
private void |
clear(Node n) |
double |
getTotalRate(byte process) |
void |
insert(T data)
Do nothing
|
boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
void |
populate()
It goes through all nodes and recomputes sum of the rates.
|
private double |
populateAtom(Node n)
Populates tree with the sum of child rates to current node.
|
private Node |
randomAtom(Node n,
double r) |
T |
randomElement()
Chooses a random atom from current tree.
|
void |
recomputeTotalRate(byte process) |
void |
remove(T atom) |
private void |
removeAtomRate(Node<T> n,
T data) |
void |
removeAtomRate(T data)
Removes atom's rate from the tree, with its old rate and sets to zero.
|
void |
reset()
Empties current tree.
|
private void |
reset(Node n) |
T |
search(T atom)
Not yet implemented.
|
int |
size() |
java.lang.String |
toString() |
private void |
updateRate(Node<T> n,
T data,
double diff) |
void |
updateRate(T data,
double diff)
Method to update rates from root to an atom.
|
private final byte process
private int occupied
private final AvlTree tree
public AtomsAvlTree(byte process, AvlTree tree)
public double getTotalRate(byte process)
getTotalRate
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
public void insert(T data)
insert
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
data
- public void updateRate(T data, double diff)
updateRate
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
data
- atom that has a delta in rate.diff
- rate to be added.public void removeAtomRate(T data)
removeAtomRate
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
data
- public java.lang.String toString()
toString
in class java.lang.Object
public void addRate(T data)
addRate
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
data
- current atom.public void clear()
clear
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
private void clear(Node n)
public void reset()
reset
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
private void reset(Node n)
public void recomputeTotalRate(byte process)
recomputeTotalRate
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
public void populate()
populate
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
private double populateAtom(Node n)
n
- public T randomElement()
randomElement
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
public void remove(T atom)
remove
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
public int size()
size
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
public boolean isEmpty()
isEmpty
in interface IAtomsCollection<T extends java.lang.Comparable<T>>
public java.util.Iterator<T> iterator()
iterator
in interface IAtomsCollection<T extends java.lang.Comparable<T>>