T
- The type of object to be contained, must extend Comparable
public class MinContainer<T extends java.lang.Object & java.lang.Comparable<? super T>>
extends java.lang.Object
HashSet
implementation, with a reference to a
minimum element in the set.Constructor and Description |
---|
MinContainer() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T t)
Add an element to the underlying
HashSet and recalculate the
minimum element in this set. |
void |
clear()
Clears the underlying
HashSet and nullifies the minimum element. |
T |
getMin()
Get the minimum element in the the underlying
HashSet |
boolean |
isEmpty() |
boolean |
remove(T t)
Remove the given element from the underlying
HashSet and
recalculate the minimum element contained within. |
public boolean add(T t)
HashSet
and recalculate the
minimum element in this set.t
- The element to add to the containerpublic boolean isEmpty()
public T getMin()
HashSet
HashSet
public boolean remove(T t)
HashSet
and
recalculate the minimum element contained within. If the underlying
HashSet
is empty, the minimum element is set to null.t
- The element to be removed from the containerpublic void clear()
HashSet
and nullifies the minimum element.