edu.claflin.finder.logic

## Class PrioritySet<T>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractQueue<E>
    - - java.util.PriorityQueue<T>
      - - edu.claflin.finder.logic.PrioritySet<T>

- Type Parameters:
    `T` - the type of object to manage in the PriorityQueue.
  All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Queue<T>

      public class PrioritySet<T>
      extends java.util.PriorityQueue<T>

  Represents a PrioritySet. Operates as an extension of the java.util.PriorityQueue in that it does not allow duplicate elements. Furthermore, it may be configured so that on addition of similar elements (i.e. elements that are equivalent via .equals() but have different weight values) the higher of the two values is kept via comparator analysis. That is to say, if a Comparator indicates that a newly added object should come BEFORE the other object in a descending order, then the old object is replaced. This can be leveraged to perform a descending-based replacement if the comparator is configured properly. (i.e. a 4 replacing a 5.)
  Version:
    1.1 May 28, 2015
  Author:
    Charles Allen Schultz II
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private boolean` | `addOverride` Boolean indicating if newer elements with a greater compare value should replace others.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PrioritySet(boolean addOverride)` Public constructor for initializing a PrioritySet.
    `PrioritySet(java.util.Comparator<T> compare, boolean addOverride)` Public constructor for initializing a PrioritySet.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(T t)` Allows additions of items that already has a copy within the set (determined by obj.equals(obj2) ) and their subsequent replacement if they are of lesser value than the new object as determined by the queue's comparator.

    - ### Methods inherited from class java.util.PriorityQueue

      `clear, comparator, contains, iterator, offer, peek, poll, remove, size, spliterator, toArray, toArray`

    - ### Methods inherited from class java.util.AbstractQueue

      `addAll, element, remove`

    - ### Methods inherited from class java.util.AbstractCollection

      `containsAll, isEmpty, removeAll, retainAll, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Collection

      `containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Field Detail

    - #### addOverride

          private final boolean addOverride

      Boolean indicating if newer elements with a greater compare value should replace others.

  - ### Constructor Detail

    - #### PrioritySet

          public PrioritySet(boolean addOverride)

      Public constructor for initializing a PrioritySet. Utilizes the natural ordering of the elements.
      Parameters:
        `addOverride` - a boolean indicating if new elements may override older ones based on the comparator's value.

    - #### PrioritySet

          public PrioritySet(java.util.Comparator<T> compare,
                             boolean addOverride)

      Public constructor for initializing a PrioritySet. Requires both a comparator for comparing elements and a boolean indicating if addOverride should be enabled.
      Parameters:
        `compare` - the Comparator to use for queue ordering.
        `addOverride` - a boolean indicating if new elements may override older ones based on the comparator's value.

  - ### Method Detail

    - #### add

          public boolean add(T t)

      Allows additions of items that already has a copy within the set (determined by obj.equals(obj2) ) and their subsequent replacement if they are of lesser value than the new object as determined by the queue's comparator.

      Specified by:
        `add` in interface `java.util.Collection<T>`
      Specified by:
        `add` in interface `java.util.Queue<T>`
      Overrides:
        `add` in class `java.util.PriorityQueue<T>`
      Parameters:
        `t` - the T type object to add.
      Returns:
        true if added, false if not.