Interpreter.Sexp.Utils
Class SexpHashtable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--Interpreter.Sexp.Utils.SexpHashtable

public class SexpHashtable
extends java.util.Hashtable

La classe SexpHashtable realizza un Environment per S-expressions. La chiave è una stringa, il valore è una Sexp .


Rispetto alla classe Hashtable sono stati ridefiniti alcuni metodi. Quelli non ridefiniti sono:

public int size(): returns the number of elements contained in the hashtable.

public boolean isEmpty(): returns true if the hashtable contains no elements.

public synchronized Enumeration keys(): returns an enumeration of the hashtable's keys.

public synchronized Enumeration elements(): returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.

public synchronized void clear(): clears the hash table so that it has no more elements in it.

public synchronized Object clone(): creates a clone of the hashtable. A shallow copy is made, the keys and elements themselves are NOT cloned. This is a relatively expensive operation.

public synchronized String toString(): converts to a rather lengthy String.

See Also:
Serialized Form

Constructor Summary
SexpHashtable()
          Costruisce un nuovo SexpHashtable vuoto.
SexpHashtable(int c)
          Costruisce un nuovo SexpHashtable vuoto.
SexpHashtable(int c, float lf)
          Costruisce un nuovo SexpHashtable vuoto.
 
Method Summary
 SexpHashtable Clone()
          Crea una deep copy dell'oggetto.
 boolean contains(Sexp value)
          Returns true if the specified Sexp object is an element of the hashtable.
 boolean containsKey(java.lang.String key)
          Returns true if the collection contains an element for the key.
 Sexp get(Sexp key)
          Gets the Sexp object associated with the specified key in the hashtable.
 Sexp get(java.lang.String key)
          Gets the Sexp object associated with the specified key in the hashtable.
 Sexp put(java.lang.String key, Sexp value)
          Puts the specified element into the hashtable, using the specified key.
 Sexp remove(java.lang.String key)
          Removes the element corresponding to the key.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SexpHashtable

public SexpHashtable()
Costruisce un nuovo SexpHashtable vuoto. La capacità iniziale ed il fattore di caricamento sono quelli di default.

SexpHashtable

public SexpHashtable(int c)
Costruisce un nuovo SexpHashtable vuoto. La capacità iniziale è quella specificata. Il fattore di caricamento è quello di default.
Parameters:
c - capacità iniziale, ovvero numero di entries iniziali.

SexpHashtable

public SexpHashtable(int c,
                     float lf)
Costruisce un nuovo SexpHashtable vuoto. La capacità iniziale ed il fattore di caricamento sono quelli specificati.
Parameters:
c - capacità iniziale, ovvero numero di entries iniziali.
lf - float compreso fra 0.0 e 1.0, rappresentante il fattore di caricamento.
Method Detail

contains

public boolean contains(Sexp value)
Returns true if the specified Sexp object is an element of the hashtable. This operation is more expensive than the containsKey() method.
Parameters:
value - the value that we are looking for
Throws:
NullPointerException - If the value being searched for is equal to null.
See Also:
Hashtable.containsKey(java.lang.Object)

containsKey

public boolean containsKey(java.lang.String key)
Returns true if the collection contains an element for the key.
Parameters:
key - the key that we are looking for
See Also:
Hashtable.contains(java.lang.Object)

get

public Sexp get(java.lang.String key)
Gets the Sexp object associated with the specified key in the hashtable.
Parameters:
key - the specified key
See Also:
Hashtable.put(java.lang.Object, java.lang.Object)

get

public Sexp get(Sexp key)
Gets the Sexp object associated with the specified key in the hashtable.
Parameters:
key - the specified key
See Also:
Hashtable.put(java.lang.Object, java.lang.Object)

put

public Sexp put(java.lang.String key,
                Sexp value)
Puts the specified element into the hashtable, using the specified key. The element may be retrieved by doing a get() with the same key. The key and the element cannot be null.
Parameters:
key - the specified key in the hashtable
value - the specified element
Returns:
the old value of the key, or null if it did not have one.
Throws:
NullPointerException - If the value of the element is equal to null.
See Also:
Hashtable.get(java.lang.Object)

remove

public Sexp remove(java.lang.String key)
Removes the element corresponding to the key. Does nothing if the key is not present.
Parameters:
key - the key that needs to be removed
Returns:
the value corresponding of the key, or null if the key was not found.

Clone

public SexpHashtable Clone()
Crea una deep copy dell'oggetto.
Returns:
un nuovo SexpHashtable che costituisce una deep copy dell'oggetto.


Codice realizzato da Francesco Geri & Marco Tamanti