18#ifndef _DECAF_UTIL_ABSTRACTCOLLECTION_H_
19#define _DECAF_UTIL_ABSTRACTCOLLECTION_H_
57 template<
typename E >
77 std::auto_ptr<Iterator<E> > iter(other.
iterator());
78 while (iter->hasNext()) {
79 this->
add(iter->next());
95 std::auto_ptr<Iterator<E> > iter(collection.
iterator());
96 while (iter->hasNext()) {
97 this->
add(iter->next());
119 std::auto_ptr<Iterator<E> > iter(this->
iterator());
120 while (iter->hasNext()) {
134 std::auto_ptr<Iterator<E> > iter(this->
iterator());
135 while (iter->hasNext()) {
136 if (iter->next() == value) {
153 std::auto_ptr<Iterator<E> > iter(collection.
iterator());
154 while (iter->hasNext()) {
155 if (!this->
contains(iter->next())) {
174 if (
this == &collection) {
178 if (this->
size() == collection.
size() && this->containsAll(collection)) {
201 std::auto_ptr<Iterator<E> > iter(collection.
iterator());
202 while (iter->hasNext()) {
203 this->
add(iter->next());
215 return this->
size() == 0;
223 virtual bool add(
const E& value DECAF_UNUSED) {
225 __FILE__, __LINE__,
"AbstractCollection add is not implemented.");
240 std::auto_ptr<Iterator<E> > iter(collection.
iterator());
241 while (iter->hasNext()) {
242 result = this->
add(iter->next()) || result;
261 std::auto_ptr<Iterator<E> > iter(this->
iterator());
262 while (iter->hasNext()) {
263 if (value == iter->next()) {
286 std::auto_ptr<Iterator<E> > iter(this->
iterator());
287 while (iter->hasNext()) {
288 if (collection.
contains(iter->next())) {
311 std::auto_ptr<Iterator<E> > iter(this->
iterator());
312 while (iter->hasNext()) {
313 if (!collection.
contains(iter->next())) {
331 std::vector<E> valueArray;
332 valueArray.reserve((std::size_t) this->
size());
334 std::auto_ptr<Iterator<E> > iter(this->
iterator());
335 while (iter->hasNext()) {
336 valueArray.push_back(iter->next());
360 virtual void wait(
long long millisecs) {
364 virtual void wait(
long long millisecs,
int nanos) {
virtual decaf::util::Iterator< E > * iterator()=0
Definition: UnsupportedOperationException.h:32
This class provides a skeletal implementation of the Collection interface, to minimize the effort req...
Definition: AbstractCollection.h:58
AbstractCollection()
Definition: AbstractCollection.h:65
virtual bool containsAll(const Collection< E > &collection) const
Returns true if this collection contains all of the elements in the specified collection.
Definition: AbstractCollection.h:151
AbstractCollection(const AbstractCollection &other)
Copy Constructor, copy element from the source collection to this collection after clearing any eleme...
Definition: AbstractCollection.h:73
virtual bool contains(const E &value) const
Returns true if this collection contains the specified element.More formally, returns true if and onl...
Definition: AbstractCollection.h:132
virtual bool isEmpty() const
Returns true if this collection contains no elements.
Definition: AbstractCollection.h:214
virtual void unlock()
Unlocks the object.
Definition: AbstractCollection.h:352
virtual bool equals(const Collection< E > &collection) const
Answers true if this Collection and the one given are the same size and if each element contained in ...
Definition: AbstractCollection.h:172
virtual void lock()
Locks the object.
Definition: AbstractCollection.h:344
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition: AbstractCollection.h:356
virtual bool add(const E &value DECAF_UNUSED)
Definition: AbstractCollection.h:223
virtual bool remove(const E &value)
Removes a single instance of the specified element from the collection.More formally,...
Definition: AbstractCollection.h:259
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition: AbstractCollection.h:368
virtual void copy(const Collection< E > &collection)
Renders this Collection as a Copy of the given Collection.
Definition: AbstractCollection.h:198
AbstractCollection< E > & operator=(const AbstractCollection< E > &collection)
Assignment Operator, copy element from the source collection to this collection after clearing any el...
Definition: AbstractCollection.h:92
virtual bool removeAll(const Collection< E > &collection)
Removes all this collection's elements that are also contained in the specified collection (optional ...
Definition: AbstractCollection.h:283
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: AbstractCollection.h:360
virtual void wait(long long millisecs, int nanos)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: AbstractCollection.h:364
virtual bool retainAll(const Collection< E > &collection)
Retains only the elements in this collection that are contained in the specified collection (optional...
Definition: AbstractCollection.h:308
util::concurrent::Mutex mutex
Definition: AbstractCollection.h:61
virtual std::vector< E > toArray() const
Answers an STL vector containing copies of all elements contained in this Collection.
Definition: AbstractCollection.h:330
virtual ~AbstractCollection()
Definition: AbstractCollection.h:83
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 tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Definition: AbstractCollection.h:348
virtual void clear()
Removes all of the elements from this collection (optional operation).
Definition: AbstractCollection.h:118
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition: AbstractCollection.h:372
The root interface in the collection hierarchy.
Definition: Collection.h:69
virtual bool contains(const E &value) const =0
Returns true if this collection contains the specified element.
virtual int size() const =0
Returns the number of elements in this collection.
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
virtual void lock()
Locks the object.
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
virtual void unlock()
Unlocks the object.
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition: AprPool.h:25