Class LRUFrontier<E>

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

    public class LRUFrontier<E>
    extends java.lang.Object
    implements Frontier<E>
    A Least Recently Used based worklist
    Author:
    Ben Holland
    • Constructor Summary

      Constructors 
      Constructor Description
      LRUFrontier()
      Creates a new frontier
      LRUFrontier​(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 frontier, moving the element to the end of the frontier if it already is contained in the frontier.
      boolean hasNext()
      Returns true if the frontier is not empty, false otherwise
      E next()
      Returns (and removes) the next element from the frontier in Least Recently Used (LRU) 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

      • LRUFrontier

        public LRUFrontier()
        Creates a new frontier
      • LRUFrontier

        public LRUFrontier​(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 Least Recently Used (LRU) order
        Specified by:
        next in interface Frontier<E>
        Returns:
      • add

        public boolean add​(E e)
        Adds the element to the frontier, moving the element to the end of the frontier if it already is contained in the frontier. 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: