#include "Map.h" #include "MapIterator.h" #include using namespace std; MapIterator::MapIterator(const Map& d) : map(d) { //O(1) this->_current=0; while (this->_currentmap._capacity && this->map._elements[this->_current]==NULL_TELEM) { this->_current++; } this->_first=this->_current; } void MapIterator::first() { //O(1) this->_current=this->_first; } void MapIterator::next() { //O(1) if(this->valid()){ this->_current++; while (this->_currentmap._capacity && this->map._elements[this->_current]==NULL_TELEM) { this->_current++; } } else throw exception(); } TElem MapIterator::getCurrent(){ //O(1) if(this->valid()) return this->map._elements[this->_current]; throw exception(); } bool MapIterator::valid() const { //O(1) if(this->_currentmap._capacity && this->map._elements[this->_current]!=NULL_TELEM) return true; return false; }