Class IntFifo


  • public class IntFifo
    extends Object
    First in first out Integer queue. The size of the queue should be a multiple of 2 minus one (size = 2^x - 1).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int[] data  
      (package private) int head  
      static int NO_DATA  
      (package private) int size  
      (package private) int tail  
    • Constructor Summary

      Constructors 
      Constructor Description
      IntFifo​(int size)
      Creates a new IntFifo with size entries.
    • Field Detail

      • data

        int[] data
      • head

        int head
      • tail

        int tail
      • size

        int size
    • Constructor Detail

      • IntFifo

        public IntFifo​(int size)
        Creates a new IntFifo with size entries.
        Parameters:
        size - The size of the queue (size = 2^x - 1).
    • Method Detail

      • enqueue

        public void enqueue​(int data)
        Inserts one Integer into the queue.
        Parameters:
        data - Integer which will be inserted into the queue
      • dequeue

        public int dequeue()
        Removes one Integer from the queue.
        Returns:
        The removed Integer or @see NO_DATA if no data is present
      • clear

        public void clear()
        Clears the queue.
      • availToRead

        public int availToRead()
        Reads the available entries in the queue.
        Returns:
        The available Integers to read.
      • availToWrite

        public int availToWrite()
        Reads the available space left in the queue.
        Returns:
        The available queue space.
      • getSize

        public int getSize()
        Reads the maximum number of entries in the queue.
        Returns:
        The size of the queue.