APTCONVERT 1.1

fr.pixware.util
Class LinearHashtable

java.lang.Object
  extended byfr.pixware.util.LinearHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public final class LinearHashtable
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A hashtable which is more compact and less efficient (modulo the fact that java.util.Hashtable is thread safe and that LinearHashtable is not thread safe) than Hashtable.

LinearHashtable has exactly the same API as java.util.Hashtable, therefore there is no need to document again this API here.

This implementation is the one used by Smalltalk. It is useful if you need to have hundreds or even thousands of very small hashtables (with up to 3 entries for most instances).

See Also:
Serialized Form

Constructor Summary
LinearHashtable()
          Constructs a hashtable with an initial capacity of 3 key/value pairs.
LinearHashtable(int capacity)
          Constructs a hashtable with the specified initial capacity.
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object value)
           
 boolean containsKey(java.lang.Object key)
           
 void copyElementsInto(java.lang.Object[] array)
          Copies the elements contained into this hashtable into the specified array.
 void copyKeysInto(java.lang.Object[] array)
          Copies the keys contained into this hashtable into the specified array.
 java.util.Enumeration elements()
           
 java.lang.Object get(java.lang.Object key)
           
 boolean isEmpty()
           
 java.util.Enumeration keys()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
          Returns the number of key/value pairs currently stored in this hashtable.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearHashtable

public LinearHashtable()
Constructs a hashtable with an initial capacity of 3 key/value pairs.


LinearHashtable

public LinearHashtable(int capacity)
Constructs a hashtable with the specified initial capacity.

Parameters:
capacity - the initial capcity expressed in number of key/value pairs
Method Detail

size

public int size()
Returns the number of key/value pairs currently stored in this hashtable. Note that calling this method is more expensive than calling Hashtable.size() because the size is recomputed each time this method is called.

Returns:
the number of key/value pairs currently stored in this hashtable

isEmpty

public boolean isEmpty()

contains

public boolean contains(java.lang.Object value)

containsKey

public boolean containsKey(java.lang.Object key)

get

public java.lang.Object get(java.lang.Object key)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)

remove

public java.lang.Object remove(java.lang.Object key)

clear

public void clear()

clone

public java.lang.Object clone()

toString

public java.lang.String toString()

copyKeysInto

public void copyKeysInto(java.lang.Object[] array)
Copies the keys contained into this hashtable into the specified array.

Parameters:
array - the array where the keys are to be copied

copyElementsInto

public void copyElementsInto(java.lang.Object[] array)
Copies the elements contained into this hashtable into the specified array.

Parameters:
array - the array where the elements are to be copied

keys

public java.util.Enumeration keys()

elements

public java.util.Enumeration elements()

APTCONVERT 1.1