|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectDictionary<K,D>
Searchtree<K,D>
K
- The type of the keys.D
- The type of the data.public class Searchtree<K extends java.lang.Comparable<K>,D>
A Searchtree is a Map
-implementation as (not necessarily balanced)
binary tree. Standard access methods like insertion, deletion, and lookup are linear
in the depth of the tree, and thus, logarithmic in the nr of entries,
if the tree is balanced.
Constructor Summary | |
---|---|
Searchtree()
|
Method Summary | |
---|---|
void |
delete(K k)
Removes the entry which stores the data for the key k. |
D |
find(K k)
Looks up the data for the given key k. |
void |
insert(K k,
D d)
Associates the data d to the key k in this map. |
boolean |
iselement(K k)
Checks whether the given key k is present in this searchtree. |
Iterator<K,D> |
iterator()
Creates a new iterator over all associations between keys and data. |
void |
opt_searchtree(int n,
Array<K> keys,
Array<java.lang.Double> p,
Array<java.lang.Double> q)
Constructs an optimal search tree in the general case with n given keys where the propabilities to access each key are stored in p and the propabilities to access values between two keys are stored in q. |
void |
print()
Prints the map to stdout |
int |
size()
Linear time implementation of Map.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 Searchtree()
Method Detail |
---|
public void insert(K k, D d)
Map
insert
in interface Map<K extends java.lang.Comparable<K>,D>
insert
in class Dictionary<K extends java.lang.Comparable<K>,D>
k
- The key to store.d
- The data associated to the key k.public void delete(K k)
delete
in interface Map<K extends java.lang.Comparable<K>,D>
delete
in class Dictionary<K extends java.lang.Comparable<K>,D>
k
- The key to delete with its associated data.public D find(K k)
find
in interface Map<K extends java.lang.Comparable<K>,D>
find
in class Dictionary<K extends java.lang.Comparable<K>,D>
k
- The key to look for, must be non-null.
Map.find(Object)
public boolean iselement(K k)
iselement
in interface Map<K extends java.lang.Comparable<K>,D>
iselement
in class Dictionary<K extends java.lang.Comparable<K>,D>
k
- The key to look for, must be non-null.
public int size()
Dictionary
Map.size()
size
in interface Map<K extends java.lang.Comparable<K>,D>
size
in class Dictionary<K extends java.lang.Comparable<K>,D>
public Iterator<K,D> iterator()
Map
iterator
in interface Map<K extends java.lang.Comparable<K>,D>
iterator
in class Dictionary<K extends java.lang.Comparable<K>,D>
Iterator
over all keys with
associated data.public void print()
Map
print
in interface Map<K extends java.lang.Comparable<K>,D>
print
in class Dictionary<K extends java.lang.Comparable<K>,D>
public void opt_searchtree(int n, Array<K> keys, Array<java.lang.Double> p, Array<java.lang.Double> q)
n
- The number of keys.keys
- The keys to store.p
- The propabilities to access a key. More precisely,
p[i] is the propability to access keys[i] for all
0 ≤ i < n.q
- The propabilities to access values between two keys.
More precisely, q[0] is the propability to ask for values smaller
than keys[0]. q[n] is the propability to ask for values larger than
keys[n-1]. And q[i] is the propability to ask for values between
keys[i-1] and keys[i] for all 1 ≤ i < n.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |