18#ifndef ABSTRACTQUEUE_H_
19#define ABSTRACTQUEUE_H_
46 template<
typename E >
61 virtual bool add(
const E& value) {
63 if (this->
offer(value)) {
68 __FILE__, __LINE__,
"Unable to add specified element to the Queue.");
80 if (
this == &collection) {
82 __FILE__, __LINE__,
"A Queue cannot be added to itself." );
98 if (this->
poll(result) ==
true) {
103 __FILE__, __LINE__,
"Unable to remove specified element from the Queue.");
115 if (this->
peek(result) ==
true) {
120 __FILE__, __LINE__,
"Unable to remove specified element from the Queue.");
135 bool successful =
true;
138 successful = this->
poll(result);
Definition IllegalArgumentException.h:31
Definition IllegalStateException.h:32
This class provides a skeletal implementation of the Collection interface, to minimize the effort req...
Definition AbstractCollection.h:58
virtual bool isEmpty() const
Returns true if this collection contains no elements.
Definition AbstractCollection.h:214
virtual bool addAll(const Collection< E > &collection)
Adds all of the elements in the specified collection to this collection.The behavior of this operatio...
Definition AbstractCollection.h:237
virtual bool add(const E &value)
Returns true if this collection changed as a result of the call.(Returns false if this collection doe...
Definition AbstractQueue.h:61
virtual E element() const
Gets but not removes the element in the head of the queue.Throws a NoSuchElementException if there is...
Definition AbstractQueue.h:112
virtual bool addAll(const Collection< E > &collection)
Adds all of the elements in the specified collection to this collection.The behavior of this operatio...
Definition AbstractQueue.h:78
AbstractQueue()
Definition AbstractQueue.h:51
virtual void clear()
Removes all of the elements from this collection (optional operation).This collection will be empty a...
Definition AbstractQueue.h:128
virtual E remove()
Gets and removes the element in the head of the queue.Throws a NoSuchElementException if there is no ...
Definition AbstractQueue.h:95
virtual ~AbstractQueue()
Definition AbstractQueue.h:53
The root interface in the collection hierarchy.
Definition Collection.h:69
Definition NoSuchElementException.h:31
A kind of collection provides advanced operations than other basic collections, such as insertion,...
Definition Queue.h:55
virtual bool peek(E &result) const =0
Gets but not removes the element in the head of the queue.
virtual bool poll(E &result)=0
Gets and removes the element in the head of the queue.
virtual bool offer(const E &value)=0
Inserts the specified element into the queue provided that the condition allows such an operation.
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25