Class WithPriority<T>

Object
WithPriority<T>
Type Parameters:
T - the element-type
All Implemented Interfaces:
Comparable<WithPriority<T>>

public class WithPriority<T> extends Object implements Comparable<WithPriority<T>>
Wraps an element of type T to ensure priority is given when the flag gpu==true.

The priority exists via an ordering of elements, where elements with flag gpu==true always precede those with gpu==false.

Author:
Owen Feehan
  • Constructor Details

    • WithPriority

      public WithPriority(T element, boolean gpu)
      Creates a new WithPriority instance.
      Parameters:
      element - The element to assign priority to.
      gpu - Whether the element is associated with a GPU, in which case, it is given priority.
  • Method Details

    • get

      public T get()
      Gets the underlying element stored in the structure.
      Returns:
      the underlying element, ignoring any priority.
    • isGPU

      public boolean isGPU()
      Is the element returned by get() associated with a GPU?
      Returns:
      true if it the element is associated with the GPU.
    • compareTo

      public int compareTo(WithPriority<T> other)
      Orders so that gpu==true has higher priority in queue to gpu==false.
      Specified by:
      compareTo in interface Comparable<T>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object