All Packages This Package Class Hierarchy Class Search Index
Class grendel.storage.Obarray
java.lang.Object | +----grendel.storage.Obarray
Base class for objects which enable interning (uniquification) of objects.
abstract class Obarray extends java.lang.Object { // Fields 3 protected Object[] array; protected int count; protected Hashtable hashtable; // Constructors 2 Obarray(); Obarray(int); // Methods 11 protected abstract Object checkHash(byte[], int, int); public void clear(); public Enumeration elements(); protected synchronized void ensureCapacity(int); public Object getObject(int); public synchronized int intern(byte[], int, int); public int intern(ByteBuf); public int intern(String); public boolean isEmpty(); protected abstract Object newInternable(byte[], int, int); public int size(); }
Fields
array
protected Object[] array
Holds unique (non-equal) objects.
count
protected int count
How much of the array is in use; we don't use Vector for this because Vector likes to expand itself by doubling its size, and we will have enough entries that that would suck.
hashtable
protected Hashtable hashtable
Hashes from object keys to index-in-the-array values. (Which are unfortunately `Integer' objects instead of ints, because the Java object model is hopelessly stupid about such things.)
Constructors
Obarray
Obarray(int default_size)
Obarray
Obarray()
Methods
checkHash
protected abstract Object checkHash(byte[] bytes, int start, int length)
Check whether there is an object representing the given subsequence of bytes in the table already. This should end up doing hashtable.get() and returning null, or an object from the table (an Integer object.)
newInternable
protected abstract Object newInternable(byte[] bytes, int start, int length)
Creates a new object (which will then be interned.)
ensureCapacity
protected synchronized void ensureCapacity(int count)
intern
public synchronized int intern(byte[] bytes, int start, int length)
Returns the numeric ID of an object containing the given bytes. This will be reused if possible; otherwise, a new one will be made and remembered in the table.
The ID-number may be turned into an interned object with getObject().
intern
public int intern(ByteBuf buf)
intern
public int intern(String s)
getObject
public Object getObject(int id)
Given a numberic ID number, converts it to the corresponding object in this table. This ID number should be one that was previously returned by the table's `intern()' method.
isEmpty
public boolean isEmpty()
size
public int size()
clear
public void clear()
elements
public Enumeration elements()
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4