|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.OAIndex<K>
public class OAIndex<K>
Open addressing backed index for arbitrary object types. Includes support for both traditional matching of keys values based on the equals() method as well as 'identity' matching where by keys are only compared with '=='. WARNING: This is currently experimental code. It exists since in theory open addressing hashing should be more efficient for hashing int values than bucket-chain hashing, which is used to back java.util.HashMap. To do list: - in fear of user stupidity, i think HashMap re-hashes the hash values returned by objects, should we? - finalize interface - rigorous benchmarks - unit tests
Field Summary |
---|
Fields inherited from interface edu.stanford.nlp.util.IndexInterface |
---|
INVALID_ENTRY |
Constructor Summary | |
---|---|
OAIndex()
|
|
OAIndex(boolean identityHash)
|
Method Summary | |
---|---|
int |
boundOnMaxIndex()
|
boolean |
contains(Object key)
|
K |
get(int idx)
Gets the object whose index is the integer argument. |
int |
indexOf(K key)
Returns the integer index of the Object in the Index or -1 if the Object is not already in the Index. |
int |
indexOf(K key,
boolean add)
Takes an Object and returns the integer index of the Object, perhaps adding it to the index first. |
Set<K> |
keySet()
|
static void |
main(String[] args)
|
int |
maxIndex()
|
int |
size()
Returns the number of indexed objects. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public OAIndex()
public OAIndex(boolean identityHash)
Method Detail |
---|
public Set<K> keySet()
public int maxIndex()
public int boundOnMaxIndex()
public K get(int idx)
IndexInterface
get
in interface IndexInterface<K>
idx
- the integer index to be queried for the corresponding argument
public String toString()
toString
in class Object
public int indexOf(K key)
IndexInterface
indexOf
in interface IndexInterface<K>
key
- the Object whose index is desired.
public boolean contains(Object key)
contains
in interface IndexInterface<K>
public int indexOf(K key, boolean add)
IndexInterface
indexOf
in interface IndexInterface<K>
key
- the Object whose index is desired.add
- Whether it is okay to add new items to the index
public static void main(String[] args) throws IOException
IOException
public int size()
IndexInterface
size
in interface IndexInterface<K>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |