SBSPSS/Utils/Libs/DaveLib/List.h
2000-12-02 18:55:49 +00:00

62 lines
1015 B
C++

/**********************/
/*** Vtx List Class ***/
/**********************/
#if !defined __VTXLIST_CLASS_HEADER__
#define __VTXLIST_CLASS_HEADER__
#include <Vector>
/*****************************************************************************/
template <class T> class CList
{
public:
int Find(T &Item)
{
int ListSize=List.size();
for (int i=0; i<ListSize; i++)
{
if (List[i]==Item) return(i);
}
return(-1);
}
int Add(T &Item)
{
int ListSize=List.size();
int Idx=Find(Item); // Check if exists
if (Idx!=-1) return(Idx);
List.push_back(Item);
return(ListSize);
}
int push_back(T &Item)
{
int ListSize=List.size();
List.push_back(Item);
return(ListSize);
}
void clear()
{
List.clear();
}
int size() {return(List.size());}
std::vector<T> &GetList() {return(List);}
T& operator []( int nIndex ) {return(List[nIndex]);}
private:
std::vector<T> List;
};
/*****************************************************************************/
#endif