18#ifndef _DECAF_UTIL_CONCURRENT_COPYONWRITEARRAYSET_H_
19#define _DECAF_UTIL_CONCURRENT_COPYONWRITEARRAYSET_H_
48 template<
typename E >
60 this->
copy(collection);
64 for (
int i = 0; i <
size; ++i) {
65 this->array.addIfAbsent(array[i]);
75 this->array.
copy(collection);
87 return this->array.
size();
94 virtual bool add(
const E& value) {
99 return this->array.
addAllAbsent(collection) > 0 ? true :
false;
115 return this->array.
remove(value);
119 return this->array.
removeAll(collection);
123 return this->array.
retainAll(collection);
132 if ((
void*)
this == &collection) {
136 const Set<E>* asSet =
dynamic_cast<const Set<E>*
> (&collection);
141 if (this->
size() != asSet->
size()) {
145 std::auto_ptr<Iterator<E> > setIter(asSet->
iterator());
149 int length = array.size();
152 while (setIter->hasNext()) {
153 E value = setIter->next();
154 int matchedAt = array.indexOf(value);
155 if (matchedAt >= 0) {
156 matched[matchedAt] =
true;
160 for (
int i = 0; i < length; ++i) {
161 if (matched[i] ==
false) {
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition ArrayPointer.h:51
virtual decaf::util::Iterator< E > * iterator()=0
AbstractSet()
Definition AbstractSet.h:50
The root interface in the collection hierarchy.
Definition Collection.h:69
virtual int size() const =0
Returns the number of elements in this collection.
Defines an object that can be used to iterate over the elements of a collection.
Definition Iterator.h:34
A collection that contains no duplicate elements.
Definition Set.h:45
Definition CopyOnWriteArrayList.h:35
int addAllAbsent(const Collection< E > &collection)
Every element in the given collection that is not already contained in this Collection is added to th...
Definition CopyOnWriteArrayList.h:821
virtual bool contains(const E &value) const
Returns true if this collection contains the specified element.
Definition CopyOnWriteArrayList.h:292
virtual bool containsAll(const Collection< E > &collection) const
Returns true if this collection contains all of the elements in the specified collection.
Definition CopyOnWriteArrayList.h:312
virtual decaf::util::Iterator< E > * iterator()
Definition CopyOnWriteArrayList.h:510
virtual bool remove(const E &value)
Removes a single instance of the specified element from the collection.
Definition CopyOnWriteArrayList.h:376
virtual int size() const
Returns the number of elements in this collection.
Definition CopyOnWriteArrayList.h:476
virtual void clear()
Removes all of the elements from this collection (optional operation).
Definition CopyOnWriteArrayList.h:279
bool addIfAbsent(const E &value)
Adds the given value to the end of this List if it is not already contained in this List.
Definition CopyOnWriteArrayList.h:786
virtual bool retainAll(const Collection< E > &collection)
Retains only the elements in this collection that are contained in the specified collection (optional...
Definition CopyOnWriteArrayList.h:433
virtual bool isEmpty() const
Definition CopyOnWriteArrayList.h:362
virtual std::vector< E > toArray() const
Returns an array containing all of the elements in this collection.
Definition CopyOnWriteArrayList.h:490
virtual void copy(const Collection< E > &collection)
Renders this Collection as a Copy of the given Collection.
Definition CopyOnWriteArrayList.h:231
virtual bool removeAll(const Collection< E > &collection)
Removes all this collection's elements that are also contained in the specified collection (optional ...
Definition CopyOnWriteArrayList.h:393
virtual bool addAll(const Collection< E > &collection)
Adds all of the elements in the specified collection to this collection.
Definition CopyOnWriteArraySet.h:98
virtual ~CopyOnWriteArraySet()
Definition CopyOnWriteArraySet.h:69
virtual bool remove(const E &value)
Removes a single instance of the specified element from the collection.
Definition CopyOnWriteArraySet.h:114
CopyOnWriteArraySet()
Definition CopyOnWriteArraySet.h:56
virtual bool contains(const E &value) const
Returns true if this collection contains the specified element.
Definition CopyOnWriteArraySet.h:106
CopyOnWriteArraySet(const E *array, int size)
Definition CopyOnWriteArraySet.h:63
virtual decaf::util::Iterator< E > * iterator()
Definition CopyOnWriteArraySet.h:78
virtual bool containsAll(const Collection< E > &collection) const
Returns true if this collection contains all of the elements in the specified collection.
Definition CopyOnWriteArraySet.h:110
virtual bool equals(const Collection< E > &collection) const
Compares the passed collection to this one, if they contain the same elements, i.e.
Definition CopyOnWriteArraySet.h:130
virtual decaf::util::Iterator< E > * iterator() const
Definition CopyOnWriteArraySet.h:82
virtual std::vector< E > toArray() const
Returns an array containing all of the elements in this collection.
Definition CopyOnWriteArraySet.h:126
virtual bool retainAll(const Collection< E > &collection)
Retains only the elements in this collection that are contained in the specified collection (optional...
Definition CopyOnWriteArraySet.h:122
CopyOnWriteArraySet(const Collection< E > &collection)
Definition CopyOnWriteArraySet.h:59
virtual int size() const
Returns the number of elements in this collection.
Definition CopyOnWriteArraySet.h:86
virtual bool add(const E &value)
Returns true if this collection changed as a result of the call.
Definition CopyOnWriteArraySet.h:94
virtual bool removeAll(const Collection< E > &collection)
Removes all this collection's elements that are also contained in the specified collection (optional ...
Definition CopyOnWriteArraySet.h:118
virtual void copy(const Collection< E > &collection)
Renders this Collection as a Copy of the given Collection.
Definition CopyOnWriteArraySet.h:74
virtual bool isEmpty() const
Definition CopyOnWriteArraySet.h:90
virtual void clear()
Removes all of the elements from this collection (optional operation).
Definition CopyOnWriteArraySet.h:102
#define NULL
Definition Config.h:33
Definition AbstractExecutorService.h:28
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25