|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.Interner
public class Interner
For interning (canonicalizing) things.
It maps any object to a unique interned version which .equals the presented object. If presented with a new object which has no previous interned version, the presented object becomes the interned version. You can tell if your object has been chosen as the new unique representative by checking whether o == intern(o). The interners use WeakHashMap, meaning that if the only pointers to an interned item are the interners' backing maps, that item can still be garbage collected. Since the gc thread can silently remove things from the backing map, there's no public way to get the backing map, but feel free to add one at your own risk. Note that in general it is just as good or better to use the static Interner.globalIntern() method rather than making an instance of Interner and using the instance-level intern(). Author: Dan Klein Date: 9/28/03
Field Summary | |
---|---|
protected static Interner |
interner
|
protected Map |
map
|
Constructor Summary | |
---|---|
Interner()
|
Method Summary | |
---|---|
static Interner |
getGlobal()
For getting the instance that global methods use. |
static Object |
globalIntern(Object o)
Returns a unique object o' that .equals the argument o. |
Object |
intern(Object o)
Returns a unique object o' that .equals the argument o. |
Set |
internAll(Set s)
Returns a unique object o' that .equals the argument o. |
static void |
main(String[] args)
Test method: interns its arguments and says whether they == themselves. |
static Interner |
setGlobal(Interner interner)
For supplying a new instance for the global methods to use. |
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static Interner interner
protected Map map
Constructor Detail |
---|
public Interner()
Method Detail |
---|
public static Interner getGlobal()
public static Interner setGlobal(Interner interner)
public static Object globalIntern(Object o)
public Object intern(Object o)
public Set internAll(Set s)
public int size()
public static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |