public final class DBObjectTable extends java.lang.Object implements java.lang.Iterable<DBObject>
A customized variant of the java.util.Hashtable class that is
tuned for use in managing DBObjects in a Ganymede DBObjectBase.
| Modifier and Type | Field and Description |
|---|---|
private int |
count
The total number of entries in the hash table.
|
private float |
loadFactor
The load factor for the hashtable.
|
private int |
modGen
Tracking value to detect concurrent modification for the
enumerations and iterators we generate.
|
private DBObject[] |
table
The hash table data.
|
private int |
threshold
Rehashes the table when count exceeds this threshold.
|
| Constructor and Description |
|---|
DBObjectTable()
Constructs a new, empty DBObjectTable with a default capacity and load
factor.
|
DBObjectTable(int initialCapacity)
Constructs a new, empty DBObjectTable with the specified initial capacity
and default load factor.
|
DBObjectTable(int initialCapacity,
float loadFactor)
Constructs a new, empty DBObjectTable with the specified initial
capacity and the specified load factor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears this DBObjectTable.
|
boolean |
contains(DBObject value)
Tests if the DBObject value is contained in this
DBObjectTable.
|
boolean |
containsKey(int key)
Tests if a DBObject with the specified object id is in this
DBObjectTable.
|
java.util.Enumeration |
elements()
Returns an enumeration of the objects in this DBObjectTable.
|
DBObject |
get(int key)
Returns the DBObject with the specified key from this
DBObjectTable, or null if no object with that id is in this
table.
|
int |
getModGen()
Returns a modification generation value for the enumerator and
iterator that are generated from this DBObjectTable.
|
DBObject |
getNoSync(int key)
Returns the DBObject with the specified key from this
DBObjectTable, or null if no object with that id is in this
table.
|
boolean |
isEmpty()
Tests if this DBObjectTable contains no objects.
|
java.util.Iterator<DBObject> |
iterator()
Returns an Iterator of the objects in this DBObjectTable.
|
void |
put(DBObject value)
Inserts a DBObject into this DBObjectTable
|
void |
putNoSync(DBObject value)
Inserts a DBObject into this DBObjectTable.
|
void |
putNoSyncNoRemove(DBObject value)
Inserts a DBObject into this DBObjectTable.
|
protected void |
rehash()
Rehashes the contents of the DBObjectTable into a
DBObjectTable with a larger capacity.
|
void |
remove(int key)
Removes the DBObject with the given id from this
DBObjectTable.
|
void |
removeNoSync(int key)
Removes the DBObject with the given id from this
DBObjectTable.
|
void |
replaceNoSync(DBObject replaceObject)
Replaces a DBObject in the table in-place without disturbing
any Iterators running.
|
int |
size()
Returns the number of objects in this DBObjectTable.
|
java.util.Collection<DBObject> |
values()
Returns a non-editable Collection view of this DBObjectTable.
|
private transient DBObject[] table
private transient int count
private int threshold
private float loadFactor
private transient int modGen
public DBObjectTable(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacity of the hashtable.loadFactor - a number between 0.0 and 1.0.java.lang.IllegalArgumentException - if the initial capacity is less
than or equal to zero, or if the load factor is less than
or equal to zero.public DBObjectTable(int initialCapacity)
initialCapacity - the initial capacity of the hashtable.public DBObjectTable()
public int getModGen()
public int size()
public boolean isEmpty()
true if this DBObjectTable contains no values;
false otherwise.public java.util.Iterator<DBObject> iterator()
Returns an Iterator of the objects in this DBObjectTable.
Use the Iterator methods on the returned object to fetch the elements sequentially.
This method allows DBObjectTable to support the Java 5 foreach loop construct.
iterator in interface java.lang.Iterable<DBObject>Iteratorpublic java.util.Enumeration elements()
Returns an enumeration of the objects in this DBObjectTable. Use the Enumeration methods on the returned object to fetch the elements sequentially.
Enumerationpublic boolean contains(DBObject value)
Tests if the DBObject value is contained in this DBObjectTable.
value - a DBObject to search for.java.lang.NullPointerException - if the value is null.public boolean containsKey(int key)
Tests if a DBObject with the specified object id is in this DBObjectTable.
key - possible object id.public DBObject getNoSync(int key)
Returns the DBObject with the specified key from this DBObjectTable, or null if no object with that id is in this table.
public DBObject get(int key)
Returns the DBObject with the specified key from this DBObjectTable, or null if no object with that id is in this table.
protected void rehash()
Rehashes the contents of the DBObjectTable into a DBObjectTable with a larger capacity. This method is called automatically when the number of keys in the hashtable exceeds this DBObjectTable's capacity and load factor.
public void putNoSync(DBObject value)
Inserts a DBObject into this DBObjectTable.
This put is not sync'ed, and should only be used with higher level sync provisions.
public void put(DBObject value)
Inserts a DBObject into this DBObjectTable
public void putNoSyncNoRemove(DBObject value)
Inserts a DBObject into this DBObjectTable.
This put is not sync'ed, and should only be used with higher level sync provisions.
public void removeNoSync(int key)
Removes the DBObject with the given id from this DBObjectTable.
public void remove(int key)
Removes the DBObject with the given id from this DBObjectTable.
public void replaceNoSync(DBObject replaceObject)
Replaces a DBObject in the table in-place without disturbing any Iterators running.
public void clear()
Clears this DBObjectTable.
public java.util.Collection<DBObject> values()
Returns a non-editable Collection view of this DBObjectTable.