Class EvictingCollection<V>

java.lang.Object
de.florianmichael.rclasses.pattern.evicting.EvictingCollection<V>
Type Parameters:
V - The type of the collection.

public final class EvictingCollection<V> extends Object
Implementation of an evicting collection. This collection will remove the first entry if the collection is full.
  • Constructor Details

    • EvictingCollection

      public EvictingCollection()
      Dummy constructor.
    • EvictingCollection

      public EvictingCollection(Collection<V> collection, int maxSize)
      Creates a new evicting collection.
      Parameters:
      collection - The collection.
      maxSize - The maximum size of the collection.
  • Method Details

    • add

      public boolean add(V value)
      Adds a value to the collection. If the collection is full, the first entry will be removed. Returns true if the collection was full.
      Parameters:
      value - The value to add.
      Returns:
      True if the collection was full.
    • isFull

      public boolean isFull()
      Returns:
      True if the collection is full.
    • getNormalCollection

      public Collection<V> getNormalCollection()
    • getMaxSize

      public int getMaxSize()