net.ontopia.utils
Class SoftValueHashMapIndex

java.lang.Object
  extended by net.ontopia.utils.SoftValueHashMapIndex
All Implemented Interfaces:
LookupIndexIF

public class SoftValueHashMapIndex
extends java.lang.Object
implements LookupIndexIF

INTERNAL: A lookup index implementation that uses soft references for the values, in order to allow them to be garbage-collected. It doesn't support a fallback, since this is not needed where it is used. It's simply a cache that allows its values to be GC-ed. Note that the keys passed in should not be SoftReferences; the index will wrap them as references where needed.

General approach is closed hashing, like in CompactHashSet. We simplify a little by assuming that null keys do not occur in put() and remove().


Nested Class Summary
static class SoftValueHashMapIndex.SoftEntry
           
 
Field Summary
 SoftValueHashMapIndex.SoftEntry[] entries
           
 
Constructor Summary
SoftValueHashMapIndex()
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
           
 java.lang.Object getKey(java.lang.Object key)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 void writeReport(java.io.Writer out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

public SoftValueHashMapIndex.SoftEntry[] entries
Constructor Detail

SoftValueHashMapIndex

public SoftValueHashMapIndex()
Method Detail

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface LookupIndexIF

getKey

public java.lang.Object getKey(java.lang.Object key)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface LookupIndexIF

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface LookupIndexIF

size

public int size()

writeReport

public void writeReport(java.io.Writer out)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2000-2012 Ontopia.