DNWA/11/wywolania/Data/stide_v1.1/Utils/tlist.h
Jakub Stefko ab1d7e2546 ...
2021-01-28 18:33:55 +01:00

28 lines
1012 B
C++
Executable File

#ifndef __TLIST_H
#define __TLIST_H
// tlist.h
// this is a base template class for lists
// it is for a list of elements. An element can be of any class, but it must
// have the operators == and = defined, so that the list can be searched
// also the operator >> must be defined for write
template <class Elem> class List {
public:
virtual Elem *Insert(const Elem &elem) {return NULL;}
// insert elem into the list
// returns a ptr to elem if elem inserted, NULL if elem was already there
// i.e. doesn't put in duplicates and returns NULL for duplicates
virtual Elem *Search(const Elem &elem) {return NULL;}
// finds the element that matchs elem and returns it. This allows assoc
// retrieval
// returns NULL if the elem is not found
virtual void Write(ostream &s) {;}
// writes out the list of elements. Requires that the element overload the
// stream output operator
virtual int Empty(void) {return 0;}
// returns true if the list is empty
};
#endif