20 #ifndef HURRICANE_SET_COLLECTION
21 #define HURRICANE_SET_COLLECTION
23 #include "hurricane/Commons.h"
25 #include "hurricane/Tabulation.h"
36 template<
class Element,
class Compare = less<Element> >
45 public:
typedef set<Element, Compare> ElementSet;
52 private:
const ElementSet* _elementSet;
53 private:
typename ElementSet::const_iterator _iterator;
55 public: Locator(
const ElementSet* elementSet)
58 _elementSet(elementSet),
61 if (_elementSet) _iterator = _elementSet->begin();
64 public:
virtual Element getElement()
const
67 return (isValid()) ? *_iterator : Element();
73 return new Locator(_elementSet);
76 public:
virtual bool isValid()
const
79 return (_elementSet && (_iterator != _elementSet->end()));
82 public:
virtual void progress()
93 private:
const ElementSet* _elementSet;
101 _elementSet(elementSet)
108 _elementSet(&elementSet)
115 _elementSet(setCollection._elementSet)
125 _elementSet = setCollection._elementSet;
132 public:
virtual Collection<Element>* getClone() const
143 return (_elementSet) ?
new Locator(_elementSet) : NULL;
146 public:
virtual unsigned getSize() const
149 return (_elementSet) ? _elementSet->size() : 0;
155 public:
virtual string _getTypeName() const
158 return _TName(
"SetCollection");
161 public:
virtual string _getString() const
165 return "<" + _getTypeName() +
" unbound>";
167 if (_elementSet->empty())
168 return "<" + _getTypeName() +
" empty>";
170 return "<" + _getTypeName() +
" " + getString(_elementSet->size()) +
">";
174 Record* _getRecord() const
177 Record* record = NULL;
178 if (!_elementSet->empty()) {
179 record =
new Record(_getString());
181 typename set<Element, Compare>::const_iterator iterator = _elementSet->begin();
182 while (iterator != _elementSet->end()) {
183 record->add(getSlot(getString(n++), *iterator));
198 template<
class Element,
class Compare>
199 inline GenericCollection<Element> getCollection(
const set<Element, Compare>& elementSet)
202 return SetCollection<Element, Compare>(elementSet);
205 template<
class Element,
class Compare>
206 inline GenericCollection<Element> getCollection(
const set<Element, Compare>* elementSet)
209 return SetCollection<Element, Compare>(elementSet);
Collection description (API)
Definition: Collection.h:39
Locator description (API)
Definition: Locator.h:33
Hurricane Collection wrapper around a std::set.
Definition: SetCollection.h:37
SetCollection(const ElementSet *elementSet=NULL)
Definition: SetCollection.h:98
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5