Class ShortIndexManager

  • All Implemented Interfaces:
    java.io.Serializable

    public class ShortIndexManager
    extends java.lang.Object
    implements java.io.Serializable
    Class to generate short indexes to be used for arrays or tables. If a location or entry in a table becomes available, the index for that location is released. This class manages the use and reuse of those indexes.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ShortIndexManager()
      Constructs an ShortIndexManager.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      short allocate()
      Returns the smallest unused index value.
      void clear()
      frees all index values.
      void deallocate​(short index)
      Returns the index value so that it can be reused.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShortIndexManager

        public ShortIndexManager()
        Constructs an ShortIndexManager.
    • Method Detail

      • allocate

        public short allocate()
        Returns the smallest unused index value.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if there are no unused indexes.
      • deallocate

        public void deallocate​(short index)
        Returns the index value so that it can be reused.
        Parameters:
        index - the index to be free'd for reuse.
      • clear

        public void clear()
        frees all index values.