Package sleep.runtime

Interface ScalarHash

  • All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    HashContainer, OrderedHashContainer

    public interface ScalarHash
    extends java.io.Serializable

    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.

    • Method Detail

      • getAt

        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

        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

        void remove​(Scalar key)
        Removes the specified scalar from the hashmap. :)
      • getData

        java.util.Map getData()
        Return the data structure backing this hash please