sleep.runtime
Interface ScalarHash
- Serializable
- HashContainer, MapWrapper
public interface ScalarHash
This interface lets you create your own scalar hash implementation.
To create a new type of scalar hash: create a class that implements the sleep.runtime.ScalarHash interface. The
scalar hash interface asks for methods that define all of the common operations on sleep hashes.
To instantiate a custom scalar hash:
Scalar temp = SleepUtils.getHashScalar(new MyHashScalar());
In the above example MyHashScalar is the class name of your new scalar hash implementation.
Keep in mind when implementing the interface below that you are defining the interface to a dictionary style
data structure.
getAt
public Scalar getAt(Scalar key)
Retrieves a scalar from the hashtable. If a scalar key does not exist then the key should be created with a
value of $null. This $null or empty scalar value should be returned by the function. This is how values are
added to Scalar hashes.
keys
public ScalarArray keys()
Returns all of the keys within the scalar hash. If a key has a $null (aka empty scalar) value the key should be
removed from the scalar hash.
remove
public void remove(Scalar key)
Removes the specified scalar from the hashmap. :)