18#ifndef _DECAF_UTIL_STLSET_H_
19#define _DECAF_UTIL_STLSET_H_
46 class SetIterator :
public Iterator<E> {
49 typename std::set<E>::iterator current;
50 typename std::set<E>::iterator previous;
51 typename std::set<E>* set;
55 SetIterator(
const SetIterator&);
56 SetIterator
operator=(
const SetIterator&);
60 SetIterator(
typename std::set<E>* set) :
61 Iterator<E>(), current(set->begin()), previous(set->begin()), set(set) {
64 virtual ~SetIterator() {}
67 if (this->current == set->end()) {
69 __FILE__, __LINE__,
"Set::Iterator::next - No more elements to return");
72 this->previous = this->current;
73 return *(this->current++);
76 virtual bool hasNext()
const {
77 return (this->current != set->end());
81 if (this->previous == set->end()) {
83 __FILE__, __LINE__,
"Set::Iterator::remove - Invalid State to call remove");
86 this->set->erase(this->previous);
87 this->previous = this->set->end();
91 class ConstSetIterator :
public Iterator<E> {
94 typename std::set<E>::const_iterator current;
95 typename std::set<E>::const_iterator previous;
96 const typename std::set<E>* set;
100 ConstSetIterator(
const ConstSetIterator&);
101 ConstSetIterator
operator=(
const ConstSetIterator&);
105 ConstSetIterator(
const typename std::set<E>* set) :
106 Iterator<E>(), current(set->begin()), previous(set->begin()), set(set) {
109 virtual ~ConstSetIterator() {}
112 if (this->current == set->end()) {
114 __FILE__, __LINE__,
"Set::Iterator::next - No more elements to return");
117 this->previous = this->current;
118 return *(this->current++);
121 virtual bool hasNext()
const {
122 return (this->current != set->end());
127 __FILE__, __LINE__,
"Set::Iterator::remove - Not Valid on a Const Iterator");
160 return new SetIterator(&values);
163 return new ConstSetIterator(&values);
172 if (setptr ==
NULL) {
176 return this->values == setptr->values;
185 if (setptr ==
NULL) {
190 this->values.clear();
191 this->values = setptr->values;
205 typename std::set<E>::const_iterator iter;
206 iter = values.find(value);
207 return iter != values.end();
214 return values.empty();
221 return (
int) values.size();
227 virtual bool add(
const E& value) {
228 return values.insert(value).second;
235 return values.erase(value) != 0;
Definition IllegalStateException.h:32
Definition UnsupportedOperationException.h:32
This class provides a skeletal implementation of the Collection interface, to minimize the effort req...
Definition AbstractCollection.h:58
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 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
This class provides a skeletal implementation of the Set interface to minimize the effort required to...
Definition AbstractSet.h:47
AbstractSet()
Definition AbstractSet.h:50
The root interface in the collection hierarchy.
Definition Collection.h:69
Defines an object that can be used to iterate over the elements of a collection.
Definition Iterator.h:34
Definition NoSuchElementException.h:31
StlSet(const StlSet &source)
Copy constructor - copies the content of the given set into this one.
Definition StlSet.h:142
virtual void clear()
Removes all of the elements from this collection (optional operation).This collection will be empty a...
Definition StlSet.h:197
virtual void copy(const Collection< E > &collection)
Renders this Collection as a Copy of the given Collection.
Definition StlSet.h:182
StlSet(const Collection< E > &source)
Copy constructor - copies the content of the given set into this one.
Definition StlSet.h:150
virtual ~StlSet()
Definition StlSet.h:154
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 StlSet.h:227
StlSet()
Default constructor - does nothing.
Definition StlSet.h:136
virtual bool remove(const E &value)
Removes a single instance of the specified element from the collection.More formally,...
Definition StlSet.h:234
Iterator< E > * iterator()
an iterator over a set of elements of type T.
Definition StlSet.h:159
virtual bool equals(const Collection< E > &collection) const
Compares the passed collection to this one, if they contain the same elements, i.e....
Definition StlSet.h:169
virtual bool isEmpty() const
Definition StlSet.h:213
virtual bool contains(const E &value) const
Returns true if this collection contains the specified element.More formally, returns true if and onl...
Definition StlSet.h:204
virtual int size() const
Definition StlSet.h:220
Iterator< E > * iterator() const
Definition StlSet.h:162
#define NULL
Definition Config.h:33
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25