Class ClockSequenceController


  • public final class ClockSequenceController
    extends Object
    Class that controls the usage of clock sequence values from 0 to 16383. It manages a pool of 16384 values. The pool is implemented as an array of 2048 bytes (16384 bits). Each bit of this array corresponds to a pool value.
    • Constructor Detail

      • ClockSequenceController

        public ClockSequenceController()
    • Method Detail

      • take

        public int take​(int take)
        Take a value from the pool. If the value to be taken is already in use, it is incremented until a free value is found and returned. In the case that all pool values are in use, the pool is cleared and the last incremented value is returned. It does nothing to negative arguments.
        Parameters:
        take - value to be taken from the pool
        Returns:
        the value to be borrowed if not used.
      • random

        public int random()
        Take a random value from the pool.
        Returns:
        the random value to be borrowed if not used.
      • isUsed

        public boolean isUsed​(int value)
        Check if a value is used out of the pool.
        Parameters:
        value - a value to be checked in the pool.
        Returns:
        true if the value is used.
      • isFree

        public boolean isFree​(int value)
        Check if a value is free in the pool.
        Parameters:
        value - a value to be checked in the pool.
        Returns:
        true if the value is free.
      • countUsed

        public int countUsed()
        Count the used values out of the pool.
        Returns:
        the count of used values.
      • countFree

        public int countFree()
        Count the free values in the pool.
        Returns:
        the count of free values.
      • clearPool

        public void clearPool()
        Clear all bits of the byte array that represents the pool. This corresponds to marking all pool values as free.