18 #ifndef _DECAF_UTIL_ABSTRACTCOLLECTION_H_ 19 #define _DECAF_UTIL_ABSTRACTCOLLECTION_H_ 57 template<
typename E >
79 std::auto_ptr< Iterator<E> > iter( collection.
iterator() );
80 while( iter->hasNext() ) {
81 this->
add( iter->next() );
104 std::auto_ptr< Iterator<E> > iter( this->
iterator() );
105 while( iter->hasNext() ) {
120 std::auto_ptr< Iterator<E> > iter( this->
iterator() );
121 while( iter->hasNext() ) {
122 if( iter->next() == value ) {
139 std::auto_ptr< Iterator<E> > iter( collection.
iterator() );
140 while( iter->hasNext() ) {
141 if( !this->
contains( iter->next() ) ) {
160 if(
this == &collection ) {
187 std::auto_ptr< Iterator<E> > iter( collection.
iterator() );
188 while( iter->hasNext() ) {
189 this->
add( iter->next() );
201 return this->
size() == 0;
211 __FILE__, __LINE__,
"AbstractCollection add is not implemented.");
226 std::auto_ptr< Iterator<E> > iter( collection.
iterator() );
227 while( iter->hasNext() ) {
228 result = this->
add( iter->next() ) || result;
245 virtual bool remove(
const E& value ) {
247 std::auto_ptr< Iterator<E> > iter( this->
iterator() );
248 while( iter->hasNext() ) {
249 if( value == iter->next() ) {
272 std::auto_ptr< Iterator<E> > iter( this->
iterator() );
273 while( iter->hasNext() ) {
274 if( collection.
contains( iter->next() ) ) {
297 std::auto_ptr< Iterator<E> > iter( this->
iterator() );
298 while( iter->hasNext() ) {
299 if( !collection.
contains( iter->next() ) ) {
317 std::vector<E> valueArray;
318 valueArray.reserve( this->
size() );
320 std::auto_ptr< Iterator<E> > iter( this->
iterator() );
321 while( iter->hasNext() ) {
322 valueArray.push_back( iter->next() );
346 virtual void wait(
long long millisecs ) {
347 mutex.
wait( millisecs );
350 virtual void wait(
long long millisecs,
int nanos ) {
351 mutex.
wait( millisecs, nanos );
The root interface in the collection hierarchy.
Definition: Collection.h:68
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
virtual void lock()
Locks the object.
Definition: AbstractCollection.h:330
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition: AbstractCollection.h:354
virtual bool add(const E &value DECAF_UNUSED)
Definition: AbstractCollection.h:209
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:294
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition: AbstractCollection.h:342
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
This class provides a skeletal implementation of the Collection interface, to minimize the effort req...
Definition: AbstractCollection.h:58
virtual std::vector< E > toArray() const
Answers an STL vector containing copies of all elements contained in this Collection.
Definition: AbstractCollection.h:316
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:334
virtual void unlock()
Unlocks the object.
virtual void unlock()
Unlocks the object.
Definition: AbstractCollection.h:338
virtual int size() const =0
Returns the number of elements in this collection.
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
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:158
Definition: UnsupportedOperationException.h:32
virtual bool contains(const E &value) const =0
Returns true if this collection contains the specified element.
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: AbstractCollection.h:346
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
virtual decaf::util::Iterator< E > * iterator()=0
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:223
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
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:76
virtual void lock()
Locks the object.
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:350
virtual bool isEmpty() const
Returns true if this collection contains no elements.
Definition: AbstractCollection.h:200
util::concurrent::Mutex mutex
Definition: AbstractCollection.h:61
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:269
virtual void clear()
Removes all of the elements from this collection (optional operation).
Definition: AbstractCollection.h:102
virtual bool containsAll(const Collection< E > &collection) const
Returns true if this collection contains all of the elements in the specified collection.The Collection to compare to this one.if the Collection contains pointers and the Collection does not allow for NULL elements (optional check).
Definition: AbstractCollection.h:137
#define DECAF_UNUSED
Definition: Config.h:160
virtual ~AbstractCollection()
Definition: AbstractCollection.h:67
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition: AbstractCollection.h:358
virtual void copy(const Collection< E > &collection)
Renders this Collection as a Copy of the given Collection.
Definition: AbstractCollection.h:184
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
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:117
AbstractCollection()
Definition: AbstractCollection.h:65