template <class T, class T2>
class Iterator
{
public:
friend class Kontener;
T (**wsk);
protected:
int actual;
T2 &container;
public:
Iterator(T2 &cont):container(cont)
{
wsk = cont.tab;
actual = 0;
}
Iterator & na_poczatek()
{
wsk = container.tab;
actual = 0;
return *this;
}
Iterator & na_koniec()
{
wsk = (container.tab + (SIZE-1));
actual = SIZE-1;
return *this;
}
Iterator & za_koniec()
{
wsk = NULL;
actual = -1;
return *this;
}
Iterator & na_wezel(int indeks)
{
wsk = (container.tab + (indeks));
actual = indeks;
return *this;
}
Iterator & operator++()
{
if(wsk && actual<(SIZE - 1))
{
wsk = (container.tab + (actual + 1));
actual += 1;
}
else
cout<<"Iterator jest juz na ostatnim miejscu lub jest poza tablica."<<endl;
return *this;
}
Iterator & operator--()
{
if(wsk && actual>0)
{
wsk = (container.tab + (actual - 1));
actual -= 1;
}
else
cout<<"Iterator jest juz na pierwszym miejscu lub jest poza tablica."<<endl;
return *this;
}
Iterator & operator*(int liczba)
{
cout<<endl<<"actual: "<<actual<<endl;
if(wsk && (liczba * actual < SIZE))
{
wsk = (container.tab + (liczba * actual));
actual = liczba * actual;
}
else
cout<<"Iterator jest poza tablica."<<endl;
return *this;
}
Iterator & operator=(Iterator &it)
{
if(&it == this)
cout<<"To ten sam iterator."<<endl;
else
{
this->actual = it.actual;
**this->wsk = **it.wsk;
}
return *this;
}
Iterator & operator==(Iterator &it)
{
if(&it == this)
cout<<"To ten sam iterator."<<endl;
else
{
if(this->actual == it.actual)
cout<<"Sa takie same."<<endl;
else
cout<<"Nie sa takie same."<<endl;
}
return *this;
}
Iterator & operator!=(Iterator &it)
{
if(&it == this)
cout<<"To ten sam iterator."<<endl;
else
{
if(this->actual != it.actual)
cout<<"Sa rozne."<<endl;
else
cout<<"Sa takie same."<<endl;
}
return *this;
}
operator int() const
{
return int(actual);
}
void wypisz()
{
cout<<"ITERATOR "<<**wsk<<endl;
}
};
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}