//#pragma once
#include <iostream>
#include <string>
using namespace std;
template <class T>
class SuperList
{
private:
T* polje;
int cnt, capacity;
public:
SuperList(int x){
cnt = 0;
polje = (T*)malloc(sizeof(T) * x);
}
~SuperList(void){}
// Dodavanje u polje
void add(T item){
if(cnt >= capacity){
capacity += 5;
polje = (T*)realloc(polje, sizeof(T) * (cnt+2));
}
polje[cnt] = item;
cnt++;
}
// Brisanje iz polja
void remove(T item){
for(int i=0; i<cnt; i++){
if(polje[i] == item){
for(int j=i; j<cnt-1; j++){
polje[j] = polje[j+1];
}
cnt--;
}
}
polje = (T*)realloc(polje, sizeof(T) * cnt);
}
// Clear All /////////////////////////////////////
void clear(){ delete[] this->polje; }
// Return Counter ////////////////////////////////
int count(){ return cnt; }
// Find and return element
T& operator[](const int index){
return polje[index];
}
// Return pointer
T* find(T item){
for(int i=0; i<cnt; i++){
if(polje[i] == item){
return &polje[i];
}
}
}
// Print Everything
void print(){
for(int i=0; i<cnt; i++){
cout << polje[i] << endl;
}
}
// Print from x to y
void print(int start, int count){
for(int i=start; i<start+count; i++){
cout << polje[i] << endl;
}
}
// Merge Lists
SuperList<T>& operator+=(SuperList<T>& other){}
};
////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
//#include "SuperList.h"
using namespace std;
int main(){
SuperList<string> lista(5);
for(int i=0; i<3; i++){
lista.add("Awesome");
}
/*for(int i=0; i<19; i+=3){
lista.remove(i);
}
cout << lista.count() << endl;
lista.print();
cout << endl << lista[4] << endl;
*/
return 0;
}