#include "SMIterator.h"
#include "SortedMap.h"
#include <exception>

using namespace std;

SMIterator::SMIterator(const SortedMap& m) : map(m){
	//Complexity: O(1)
	this->current = this->map.head;

}

void SMIterator::first(){
	//Complexity: O(1)
	this->current = this->map.head;
}

void SMIterator::next(){
	//Complexity: O(1)
	if (this->current == nullptr)
		throw exception();
	this->current = this->current->next;
}

bool SMIterator::valid() const{
	//Complexity: O(1)
	if(this->current == nullptr)
		return false;
	return true;
}

TElem SMIterator::getCurrent() const{
	//Complexity: O(1)
	if(this->current==nullptr)
		throw exception();
	return this->current->element;
}


