School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,55 @@
#include "Map.h"
#include "MapIterator.h"
#include <exception>
using namespace std;
MapIterator::MapIterator(const Map& d) : map(d)
{
//O(1)
this->_current=0;
while (this->_current<this->map._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->_current<this->map._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->_current<this->map._capacity && this->map._elements[this->_current]!=NULL_TELEM)
return true;
return false;
}