|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectDictionary<K,D>
Searchtree<K,D>
Treap<K,D>
K - The type of keys to store.D - The type of data to store.public class Treap<K extends java.lang.Comparable<K>,D>
A treap is like a search-tree where the nodes are annotated with weights/priorities. Then it is assured that the nodes are a heap w.r.t. to the weights and a search-tree w.r.t. the keys, i.e., for every node its weight is smaller than that of all nodes below it. Insertion, deletion, etc. are performed in logarithmic time in average.
| Constructor Summary | |
|---|---|
Treap()
Constructs a new, empty Treap |
|
Treap(int seed)
Constructs a new, empty Treap with given random seed. |
|
| Method Summary | |
|---|---|
void |
delete(K k)
Removes the entry which stores the data for the key k. |
int |
getpriority(K k)
Returns the priority(weight) for the node stored under key k. |
void |
insert(K k,
D d)
Associates the data d to the key k in this map. |
void |
insert(K k,
D d,
int weight)
Associates the data d to the key k in this map. |
| Methods inherited from class Searchtree |
|---|
find, iselement, iterator, opt_searchtree, print, size |
| Methods inherited from class Dictionary |
|---|
array, isempty, simpleiterator |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Treap()
public Treap(int seed)
seed - The random seed to initialize the random number
generator.| Method Detail |
|---|
public void insert(K k,
D d)
insert in interface Map<K extends java.lang.Comparable<K>,D>insert in class Searchtree<K extends java.lang.Comparable<K>,D>k - The key to store.d - The data to store.Map.insert(Object, Object)
public void insert(K k,
D d,
int weight)
k - The key to store.d - The data to store.weight - The weight for the newly inserted node.Map.insert(Object, Object)public void delete(K k)
delete in interface Map<K extends java.lang.Comparable<K>,D>delete in class Searchtree<K extends java.lang.Comparable<K>,D>k - The key to delete with its associated data.public int getpriority(K k)
k - A key which must be present in this treap.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||