com.knowgate.misc
Class StringHeap

java.lang.Object
  |
  +--com.knowgate.misc.StringHeap

public class StringHeap
extends java.lang.Object

This class is a simple heap structure for sorting Strings lexicographically. It is mainly used in WebMail for generating a sorted output of Hashkeys.

Version:

Field Summary
(package private)  java.lang.String[] keys
           
(package private)  int num_entries
           
 
Constructor Summary
StringHeap(int capacity)
           
 
Method Summary
protected  void decrease(int cur_pos)
          Lower an element in the heap structure Note that the cur_pos is actually one larger than the position in the array!
protected  void increase(int cur_pos)
          Lift an element in the heap structure Note that the cur_pos is actually one larger than the position in the array!
 void insert(java.lang.String key)
          Insert a key/value pair Reorganize Heap afterwards
 boolean isEmpty()
           
 java.lang.String next()
          Return and delete the key with the lowest long value.
 void remove(java.lang.String key)
          Remove an Object from the Heap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

num_entries

int num_entries

keys

java.lang.String[] keys
Constructor Detail

StringHeap

public StringHeap(int capacity)
Method Detail

insert

public void insert(java.lang.String key)
Insert a key/value pair Reorganize Heap afterwards


next

public java.lang.String next()
Return and delete the key with the lowest long value. Reorganize Heap.


isEmpty

public boolean isEmpty()

remove

public void remove(java.lang.String key)
Remove an Object from the Heap. Unfortunately not (yet) of very good complexity since we are doing a simple linear search here.

Parameters:
key - The key to remove from the heap

increase

protected void increase(int cur_pos)
Lift an element in the heap structure Note that the cur_pos is actually one larger than the position in the array!


decrease

protected void decrease(int cur_pos)
Lower an element in the heap structure Note that the cur_pos is actually one larger than the position in the array!