public class Interner<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static Interner<java.lang.Object> |
interner |
protected java.util.Map<T,java.lang.ref.WeakReference<T>> |
map |
Constructor and Description |
---|
Interner() |
Interner(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
clear(int initialCapacity) |
static Interner<java.lang.Object> |
getGlobal()
For getting the instance that global methods use.
|
static <T> T |
globalIntern(T o)
Returns a unique object o' that .equals the argument o.
|
T |
intern(T o)
Returns a unique object o' that .equals the argument o.
|
java.util.Set<T> |
internAll(java.util.Set<T> s)
Returns a
Set such that each element in the returned set
is a unique object e' that .equals the corresponding element e in the
original set. |
static void |
main(java.lang.String[] args)
Test method: interns its arguments and says whether they == themselves.
|
static Interner<java.lang.Object> |
setGlobal(Interner<java.lang.Object> interner)
For supplying a new instance for the global methods to use.
|
int |
size() |
protected static Interner<java.lang.Object> interner
public static Interner<java.lang.Object> getGlobal()
public static Interner<java.lang.Object> setGlobal(Interner<java.lang.Object> interner)
public static <T> T globalIntern(T o)
public void clear()
public void clear(int initialCapacity)
public T intern(T o)
public java.util.Set<T> internAll(java.util.Set<T> s)
Set
such that each element in the returned set
is a unique object e' that .equals the corresponding element e in the
original set.public int size()
public static void main(java.lang.String[] args)