Class FIFOFrontier<E>

  • Type Parameters:
    E -
    All Implemented Interfaces:
    Frontier<E>

    public class FIFOFrontier<E>
    extends java.lang.Object
    implements Frontier<E>
    A First In First Out based worklist
    Author:
    Ben Holland
    • Constructor Summary

      Constructors 
      Constructor Description
      FIFOFrontier()
      Creates a new frontier
      FIFOFrontier​(int initialCapacity)
      Creates a new frontier with the given initial capacity
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E e)
      Adds the element to the end of frontier, if the element already exists the frontier is left unchanged.
      boolean hasNext()
      Returns true if the frontier is not empty, false otherwise
      E next()
      Returns (and removes) the next element from the frontier in First in First out (FIFO) order
      long size()
      Returns the number of elements in this frontier set (its cardinality).
      java.lang.String toString()
      Returns a string representation of this frontier collection.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FIFOFrontier

        public FIFOFrontier()
        Creates a new frontier
      • FIFOFrontier

        public FIFOFrontier​(int initialCapacity)
        Creates a new frontier with the given initial capacity
        Parameters:
        initialCapacity -
    • Method Detail

      • hasNext

        public boolean hasNext()
        Returns true if the frontier is not empty, false otherwise
        Specified by:
        hasNext in interface Frontier<E>
        Returns:
      • next

        public E next()
        Returns (and removes) the next element from the frontier in First in First out (FIFO) order
        Specified by:
        next in interface Frontier<E>
        Returns:
      • add

        public boolean add​(E e)
        Adds the element to the end of frontier, if the element already exists the frontier is left unchanged. Returns true if the element was added, false if the element already existed.
        Specified by:
        add in interface Frontier<E>
        Parameters:
        e -
        Returns:
      • size

        public long size()
        Returns the number of elements in this frontier set (its cardinality).
        Specified by:
        size in interface Frontier<E>
        Returns:
      • toString

        public java.lang.String toString()
        Returns a string representation of this frontier collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).
        Specified by:
        toString in interface Frontier<E>
        Overrides:
        toString in class java.lang.Object
        Returns: