Removed Iterator class

There is no need to implement `Array::Iterator`.
It is replaced by returning `end()` and `begin()`

Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
This commit is contained in:
Ricardo Quesada 2013-08-21 20:03:45 -07:00
parent f0a2f6cbf8
commit 4dc18029b7
1 changed files with 6 additions and 41 deletions

View File

@ -397,53 +397,18 @@ public:
const_iterator cbegin() { return data.cbegin(); }
const_iterator cend() { return data.cend(); }
#else
class ArrayIterator : public std::iterator<std::input_iterator_tag, Object>
{
public:
ArrayIterator(int index, Array *array) : _index(index), _parent(array) {}
ArrayIterator(const ArrayIterator& arrayIterator) : _index(arrayIterator._index), _parent(arrayIterator._parent) {}
ArrayIterator& operator++()
{
++_index;
return *this;
}
ArrayIterator operator++(int dummy)
{
ArrayIterator tmp(*this);
(*this)++;
return tmp;
}
bool operator==(const ArrayIterator& rhs) { return _index == rhs._index; }
bool operator!=(const ArrayIterator& rhs) { return _index != rhs._index; }
Object* operator*() { return _parent->getObjectAtIndex(_index); }
Object* operator->() { return _parent->getObjectAtIndex(_index); }
private:
int _index;
Array *_parent;
};
// functions for range-based loop
typedef ArrayIterator iterator;
typedef ArrayIterator const_iterator;
iterator begin();
iterator end();
#endif
public:
#if CC_USE_ARRAY_VECTOR
std::vector<RCPtr<Object>> data;
#else
Object** begin() { return &data->arr[0]; }
Object** end() { return &data->arr[data->num]; }
ccArray* data;
#endif
//protected:
Array();
Array(unsigned int capacity);
};
// end of data_structure group