Class Fifo


  • public class Fifo
    extends java.lang.Object
    A simple variable length first-in first-out queue.
    • Constructor Summary

      Constructors 
      Constructor Description
      Fifo()
      Create a buffer with a default initial size.
      Fifo​(int initialSlots)
      Create a buffer with a specified initial size.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void flush()
      Flush all entries from the buffer.
      void insert​(java.lang.Object obj)
      Insert an entry into the buffer.
      boolean isEmpty()
      Check if the buffer has an entries or not.
      java.lang.Object remove()
      Remove an entry from the buffer if one is available.
      int size()
      Return the number of entries currently in the fifo.
      • Methods inherited from class java.lang.Object

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

      • Fifo

        public Fifo()
        Create a buffer with a default initial size.
      • Fifo

        public Fifo​(int initialSlots)
        Create a buffer with a specified initial size.
        Parameters:
        initialSlots - The number of initial slots in the buffer; the number of slots required by the buffer will be expanded as required.
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Check if the buffer has an entries or not.
        Returns:
        true if the buffer has no entries, and false otherwise.
      • size

        public int size()
        Return the number of entries currently in the fifo.
        Returns:
        The number of entries currently in the fifo
      • insert

        public void insert​(java.lang.Object obj)
        Insert an entry into the buffer. The buffer will be increased in size if necessary to accommodate the new entry.
        Parameters:
        obj - The object to be inserted. It must not be null.
      • remove

        public java.lang.Object remove()
        Remove an entry from the buffer if one is available.
        Returns:
        The next object in line to be removed, if one is available, or null if none are available.
      • flush

        public void flush()
        Flush all entries from the buffer.