edu.vt.marian.search
Class InsertionOrderWtdObjTable
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--edu.vt.marian.search.FullIDTable
|
+--edu.vt.marian.search.WtdObjTable
|
+--edu.vt.marian.search.InsertionOrderWtdObjTable
- public class InsertionOrderWtdObjTable
- extends WtdObjTable
- implements java.util.Enumeration
Provides hash table functionality for (singly-linked) weighted
objects keyed on FullIDs, implicitly ordered on the order in which they
were inserted. This class is essentially a wrapper around
WtdObjTable to impose the insertion order semantics.
This method implicitly relies upon the hashCode method to be
defined in the object that is going to be used as a key object.
- See Also:
WtdObjTable,
WtdObjSingleLink,
WtdObj,
Hashtable,
Debug, Serialized Form
|
Field Summary |
protected edu.vt.marian.common.FullID |
first
FullID key of first item inserted into table, for resetting
order for enumerations |
protected edu.vt.marian.common.FullID |
prevKeyInserted
FullID key of the WtdObj we last inserted into the list, for
maintaining insertion ordering |
|
Constructor Summary |
InsertionOrderWtdObjTable(edu.vt.marian.common.Debug debug)
Create an empty hash table for (singly-linked) weighted objects |
InsertionOrderWtdObjTable(int initialCapacity,
edu.vt.marian.common.Debug debug)
Create an empty hash table for (singly-linked) weighted objects
specifying initial capacity, but with default load factor. |
InsertionOrderWtdObjTable(int initialCapacity,
float loadFactor,
edu.vt.marian.common.Debug debug)
Create an empty hash table for (singly-linked) weighted objects
specifying initial capacity and load factor. |
|
Method Summary |
void |
clear()
Clear hash table. |
java.util.Enumeration |
elements()
Return an Enumeration for the weighted objects in this table. |
java.lang.Object |
insert(edu.vt.marian.common.WtdObj wtdObj)
Add a weighted object to the table. |
java.lang.Object |
nextElement()
Return the next weighted object element in this table's enumeration. |
java.lang.String |
profile()
|
java.lang.String |
toString()
|
| Methods inherited from class java.util.Hashtable |
clone,
contains,
containsKey,
containsValue,
entrySet,
equals,
get,
hashCode,
isEmpty,
keys,
keySet,
put,
putAll,
rehash,
remove,
size,
values |
| Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
prevKeyInserted
protected edu.vt.marian.common.FullID prevKeyInserted
- FullID key of the WtdObj we last inserted into the list, for
maintaining insertion ordering
first
protected edu.vt.marian.common.FullID first
- FullID key of first item inserted into table, for resetting
order for enumerations
InsertionOrderWtdObjTable
public InsertionOrderWtdObjTable(edu.vt.marian.common.Debug debug)
- Create an empty hash table for (singly-linked) weighted objects
InsertionOrderWtdObjTable
public InsertionOrderWtdObjTable(int initialCapacity,
float loadFactor,
edu.vt.marian.common.Debug debug)
- Create an empty hash table for (singly-linked) weighted objects
specifying initial capacity and load factor.
- Parameters:
initialCapacity - initial size of hash tableloadFactor - occupancy threshold before growth neededdebug - debugging object
InsertionOrderWtdObjTable
public InsertionOrderWtdObjTable(int initialCapacity,
edu.vt.marian.common.Debug debug)
- Create an empty hash table for (singly-linked) weighted objects
specifying initial capacity, but with default load factor.
- Parameters:
initialCapacity - initial size of hash tabledebug - debugging object
insert
public java.lang.Object insert(edu.vt.marian.common.WtdObj wtdObj)
- Add a weighted object to the table. This not only adds the weighted
object, but also makes the previously inserted weighted object
point to this one, to effect a linked list of weighted objects
in insertion order.
- Parameters:
wtdObj - weighted object to be inserted- Returns:
- null if the weighted object was not already present,
otherwise return the Object that was already there.
elements
public java.util.Enumeration elements()
- Return an Enumeration for the weighted objects in this table.
We actually return this object, but set up to point to the
first element in the table, ready for nextElement() and
hasMoreElements(). This first element is actually the one
pointed to by prevKeyInserted.
- Returns:
- Enumeration containing weighted object elements in table
- Overrides:
- elements in class WtdObjTable
- See Also:
nextElement(),
WtdObjTable.hasMoreElements()
nextElement
public java.lang.Object nextElement()
throws java.util.NoSuchElementException
- Return the next weighted object element in this table's enumeration.
Also, set up the enum to be the next weighted object in the
threaded sequence.
- Specified by:
- nextElement in interface java.util.Enumeration
- Returns:
- Object that is the next in the sequence
- Overrides:
- nextElement in class WtdObjTable
- See Also:
Enumeration.nextElement()
clear
public void clear()
- Clear hash table. This basically just calls the superclass
clear() method, but also resets enum and prevKeyInserted
to null to reflect initial table status.
- Overrides:
- clear in class java.util.Hashtable
- See Also:
Hashtable
toString
public java.lang.String toString()
- Overrides:
- toString in class FullIDTable
profile
public java.lang.String profile()