|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.equitysoft.hashstore.DiskHashtable | +--com.equitysoft.hashstore.DuplicateDiskHashtable
This class is an extension of DiskHashTable that allows duplicate (ie. non-unique) keys
To retrieve values the programmer should first use get
followed by repeated invocations of
getNext
to retrieve all the duplicate entries for a given key.
Caution should be exercised over how many duplicates of a key are added. The duplicates form a chain and each new duplicate is added to the end of the chain. This class maintains a "current entry" pointer to allow traversing and deletion of entries. After hundreds of duplicates are added, performance may become a problem when adding or deleting since the end of the chain has to be found. Retrieval should never be a problem.
None of the methods are synchronized. The class SyncDuplicateDiskHashtable
provides a
synchronized version.
Constructor Summary | |
DuplicateDiskHashtable(java.io.File root)
|
Method Summary | |
java.lang.Object |
get(java.lang.Object key)
Gets the object associated with the the first instance of the key. |
java.lang.Object |
getCurrentKey()
Returns the current key value or null if none is set. |
java.lang.Object |
getCurrentValue()
Returns the value associated with the current key value or null if no current key is set. |
java.lang.Object |
getNext()
This method can be repeatedly called after invoking get in order to retrieve all entries in the tabel
with the same key. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Puts the specified key and value pair into the table even though the key value may
already exist in the table. |
java.lang.Object |
remove(java.lang.Object key)
Remove all entries that match the given key. |
java.lang.Object |
removeCurrent()
Removes the current entry in the table. |
Methods inherited from class com.equitysoft.hashstore.DiskHashtable |
clear, containsKey, deleteTable, elements, isEmpty, keys, size |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DuplicateDiskHashtable(java.io.File root)
Method Detail |
public java.lang.Object put(java.lang.Object key, java.lang.Object value) throws java.io.IOException
key
and value
pair into the table even though the key value may
already exist in the table. The current key value is set to this entry.put
in class DiskHashtable
null
. The returned value is necessary for compatability with the super-class.getCurrentKey()
public java.lang.Object get(java.lang.Object key) throws java.io.IOException
getNext()
to retrieve subsequent values with the same key.
If the object causes a ClassNotFoundException
when deserializing.
, then the exception is transformed into an IOException
for convenience.get
in class DiskHashtable
null
if the key isn't found otherwise the associated objectgetNext()
public java.lang.Object getNext() throws java.io.IOException
get
in order to retrieve all entries in the tabel
with the same key.null
if the key isn't found otherwise the value associated with the next key entryget(Object)
public java.lang.Object remove(java.lang.Object key) throws java.io.IOException
remove
in class DiskHashtable
null
. Returning something is necessary for compatability with the super-class.removeCurrent()
public java.lang.Object getCurrentKey() throws java.io.IOException
public java.lang.Object getCurrentValue() throws java.io.IOException
public java.lang.Object removeCurrent() throws java.io.IOException
get
followed
by repeated calls to getNext
to move to the entry to be deleted. After deletion the current entry
becomes the following entry with the same key value if there is one.get(Object)
,
getNext()
,
remove(Object)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |