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() ) {
70 "Set::Iterator::next - No more elements to return" );
73 this->previous = this->current;
74 return *( this->current++ );
77 virtual bool hasNext()
const {
78 return ( this->current != set->end() );
81 virtual void remove() {
82 if( this->previous == set->end() ) {
85 "Set::Iterator::remove - Invalid State to call remove" );
88 this->
set->erase( this->previous );
89 this->previous = this->
set->end();
93 class ConstSetIterator :
public Iterator<E> {
96 typename std::set<E>::const_iterator current;
97 typename std::set<E>::const_iterator previous;
98 const typename std::set<E>*
set;
102 ConstSetIterator(
const ConstSetIterator& );
103 ConstSetIterator
operator= (
const ConstSetIterator& );
107 ConstSetIterator(
const typename std::set<E>*
set ) :
108 Iterator<E>(), current( set->begin() ), previous( set->begin() ),
set(
set ) {
111 virtual ~ConstSetIterator() {}
114 if( this->current == set->end() ) {
117 "Set::Iterator::next - No more elements to return" );
120 this->previous = this->current;
121 return *( this->current++ );
124 virtual bool hasNext()
const {
125 return ( this->current != set->end() );
128 virtual void remove() {
131 "Set::Iterator::remove - Not Valid on a Const Iterator" );
166 return new SetIterator( &values );
169 return new ConstSetIterator( &values );
178 if( setptr ==
NULL ) {
182 return this->values == setptr->values;
191 if( setptr ==
NULL ) {
196 this->values.clear();
197 this->values = setptr->values;
211 typename std::set<E>::const_iterator iter;
212 iter = values.find( value );
213 return iter != values.end();
220 return values.empty();
227 return (
int)values.size();
233 virtual bool add(
const E& value ) {
234 return values.insert( value ).second;
240 virtual bool remove(
const E& value ) {
241 return values.erase( value ) != 0;
virtual int size() const
Definition: StlSet.h:226
The root interface in the collection hierarchy.
Definition: Collection.h:68
virtual bool isEmpty() const
Definition: StlSet.h:219
#define NULL
Definition: Config.h:33
virtual void copy(const Collection< E > &collection)
Renders this Collection as a Copy of the given Collection.The default implementation iterates over th...
Definition: StlSet.h:188
Iterator< E > * iterator()
an iterator over a set of elements of type T.
Definition: StlSet.h:165
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:233
Defines an object that can be used to iterate over the elements of a collection.
Definition: Iterator.h:34
StlSet(const Collection< E > &source)
Copy constructor - copies the content of the given set into this one.
Definition: StlSet.h:156
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
Set template that wraps around a std::set to provide a more user-friendly interface and to provide co...
Definition: StlSet.h:39
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
Iterator< E > * iterator() const
Definition: StlSet.h:168
virtual ~StlSet()
Definition: StlSet.h:160
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:210
Definition: IllegalStateException.h:32
StlSet(const StlSet &source)
Copy constructor - copies the content of the given set into this one.
Definition: StlSet.h:147
virtual void clear()
Removes all of the elements from this collection (optional operation).The collection will be empty af...
Definition: StlSet.h:203
StlSet()
Default constructor - does nothing.
Definition: StlSet.h:140
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: StlSet.h:175
Definition: NoSuchElementException.h:31
This class provides a skeletal implementation of the Set interface to minimize the effort required to...
Definition: AbstractSet.h:46
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