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,39 @@
#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;
}