T - type of elements in the queuepublic class SetQueue<T> extends Object
A generic queue-like implementation (supporting operations addIfNotPresent,
poll, contains, and isEmpty)
which restricts a queue element to appear at most once.
If the element is already present addIfNotPresent(T) returns false.
null.
| Constructor and Description |
|---|
SetQueue() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addIfNotPresent(T item)
Add an element to the back of the queue and return
true, or else return false. |
void |
clear()
Remove all items from the queue.
|
boolean |
contains(T item) |
boolean |
isEmpty() |
T |
poll()
Remove the head of the queue and return it.
|
boolean |
remove(T item)
Remove item from queue, if present.
|
public boolean addIfNotPresent(T item)
true, or else return false.item - to addtrue if the element was added, false if it is already present.public T poll()
null if the queue is empty.public boolean contains(T item)
item - to look for in queuetrue if and only if item is in the queue.public boolean isEmpty()
true if and only if the queue is empty.public boolean remove(T item)
item - to removetrue if and only if item was initially present and was removed.public void clear()
Copyright © 2021 VMware, Inc. or its affiliates.. All rights reserved.