jclass
Class SyncSimpleHashtable
java.lang.Object
|
+--jclass.SyncSimpleHashtable
- public class SyncSimpleHashtable
- extends java.lang.Object
A simple synchronized static allocated hashtable with numeric
pozitive integer keys only.
It should be fast so no parameter checkings are performed.
Written: Radu Sion
Version: 0.11
Source: SyncSimpleHashtable.java
Visit
Smart Software
Method Summary |
int |
active()
Returns the number of objects in the hashtable. |
java.util.Vector |
get(int key)
Gets a vector of objects with a specified key from the table. |
void |
put(java.lang.Object obj,
int key)
Puts a object with a specified key in the array. |
void |
remove(int key,
int objectnumber)
Removes a specific object characterized by it's key and by the order
he got into the table, between the objects with the same key. |
void |
removeall(int key)
Removes all the objects with a specified key. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
SyncSimpleHashtable
public SyncSimpleHashtable(int size)
- Creates a new hashtable of a given size.
No parameter checkings are performed.
- Parameters:
size
- Number of empty slots to allocate static
active
public int active()
- Returns the number of objects in the hashtable.
(Kinda slow)
put
public void put(java.lang.Object obj,
int key)
- a object with a specified key in the array. There may be
more equal objects with the same key by using this method.
No parameter checkings are performed.
- Parameters:
obj
- The object to use (may be also null)key
- Objects key (should be >= 0)
removeall
public void removeall(int key)
- Removes all the objects with a specified key.
- Parameters:
The
- key of the objects to remove from the table
remove
public void remove(int key,
int objectnumber)
- Removes a specific object characterized by it's key and by the order
he got into the table, between the objects with the same key. That is
that if for example we enter the first time a object with a specific key,
then that object will be removed when we call this method with the
parameters set to that key and objectnumber=1. The next time we issue
this same function with the same parameters, the second entered object
with that key will be removed etc. Another example:
Assume we put 7 diferent objects with the same key in the hashtable
and we issue the call remove(key,1) then the first entered will be removed
and the rest will be shifted one position to left. If we issue
remove(key,4) then the first three objects remain in place object 4
vanishes and the rest of 3 objects get shifted to the left, near to the
first three ones. If we do again remove(key,4) we obtain of course
something according only to the remaining 6 objects. etc.
No parameter checkings are performed.
- Parameters:
key
- Key of the object to removeobjectnumber
- Number identifying a object between others with the same key
get
public java.util.Vector get(int key)
- Gets a vector of objects with a specified key from the table.
No parameter checkings are performed.
- Parameters:
key
- The common key- Returns:
- A vector of objects with that key (may be null)