Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#ifndef CPP008
#define CPP008
#include "ctlist.h"
template <class Typer>
linlist<Typer>::linlist()
{
First = NULL;
current = NULL;
}
template <class Typer>
int linlist<Typer>::Empty()
{
if (First == NULL)
return 1;
return 0;
}
template <class Typer>
int linlist<Typer>::TheEnd()
{
if ((*current).GetNext() == NULL)
return 1;
return 0;
}
template <class Typer>
void linlist<Typer>::move()
{
if ((!Empty())&&(!TheEnd()))
current = (*current).GetNext();
}
template <class Typer>
Typer linlist<Typer>::GetDate()
{
return (*current).GetFig();
}
template <class Typer>
void linlist<Typer>::tobegin()
{
current = First;
}
template <class Typer>
void linlist<Typer>::add(Typer NewDate)
{
ListEl<Typer>* P;
P = new ListEl<Typer>;
(*P).SetFig(NewDate);
(*P).SetNext(First);
if (Empty())
current = P;
First = P;
}
template <class Typer>
void linlist<Typer>::del()
{
if (!Empty())
{
if (current == First)
{
First = (*current).GetNext();
delete current;
tobegin();
}
else
{
ListEl<Typer>* P=First;
while ((*P).GetNext() != current)
P = (*P).GetNext();
(*P).SetNext((*current).GetNext());
delete current;
current = P;
}
}
}
template <class Typer>
Typer linlist<Typer>::GetCur()
{
Typer F=GetDate();
del();
return F;
}
/*
template <class Typer>
void linlist<Typer>::out()
{
if (!Empty())
{
ListEl<Typer>* P;
P = First;
while (P != NULL)
{
((*P).GetFig()).out();
P = (*P).GetNext();
};
cout<<endl;
}
else
cout<<"Empty list"<<endl;
}
*/
/*
template <class Typer>
int linlist<Typer>::delbyname(Typer Name)
{
int A = 0;
tobegin();
if (!Empty())
{
Typer H;
while (!TheEnd())
{
H=(*current).GetFig();
if ( H.Equil(Name) )
{
A = 1;
del();
}
move();
};
H=(*current).GetFig();
if (H.Equil(Name))
{
A = 1;
del();
}
};
tobegin();
return A;
}
*/
/*
template <class Typer>
int linlist<Typer>::inlist(Typer Date)
{
ListEl<Typer>* P = First;
Typer H;
while (P != NULL)
{
H = (*P).GetFig();
if (H.Equil(Date))
{
current = P;
return 1;
}
P = (*P).GetNext();
}
return 0;
}
*/
template <class Typer>
void linlist<Typer>::Set(linlist<Typer> L)
{
while (!Empty())
{
L.tobegin();
del();
};
if (!L.Empty())
{
L.tobegin();
while (!L.TheEnd())
{
add(L.GetDate());
L.move();
};
add(L.GetDate());
}
}
template <class Typer>
linlist<Typer>::~linlist()
{
/* while (!Empty())
{
tobegin();
del();
} */
}
/*
void main()
{
int Ch=5;
int X;
intc P;
linlist<intc> L;
while (Ch!=4)
{
cout<<"list: ";
L.out();
cout<<"curel: ";
(L.GetDate()).out();
cout<<endl<<endl;
cin>>Ch;
if (Ch == 1)
L.move();
else
if (Ch == 2)
{
cin>>X;
P.Set(X);
L.add(P);
}
else
if (Ch == 3)
L.del();
else
if (Ch == 0)
L.tobegin();
}
} */
#endif
Соседние файлы в папке Курсовая работа Обмен сообщениями по схеме Клиент-Сервер