public class Interner<T> extends Object
Modifier and Type | Field and Description |
---|---|
protected static Interner<Object> |
interner |
protected Map<T,WeakReference<T>> |
map |
Constructor and Description |
---|
Interner() |
Interner(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
clear(int initialCapacity) |
static Interner<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.
|
Set<T> |
internAll(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(String[] args)
Test method: interns its arguments and says whether they == themselves.
|
static Interner<Object> |
setGlobal(Interner<Object> interner)
For supplying a new instance for the global methods to use.
|
int |
size() |
protected Map<T,WeakReference<T>> map
public static Interner<Object> getGlobal()
public static Interner<Object> setGlobal(Interner<Object> interner)
public static <T> T globalIntern(T o)
public void clear()
public void clear(int initialCapacity)
public T intern(T o)
public Set<T> internAll(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(String[] args)