SBSPSS/Utils/Libs/DaveLib/List.h

65 lines
1.2 KiB
C
Raw Normal View History

2000-12-06 20:29:40 +01:00
/******************/
/*** List Class ***/
/******************/
2000-12-02 19:55:49 +01:00
2000-12-06 20:29:40 +01:00
#pragma warning( disable : 4786 )
#if !defined __LIST_CLASS_HEADER__
#define __LIST_CLASS_HEADER__
2000-12-02 19:55:49 +01:00
#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);
}
2000-12-06 20:29:40 +01:00
void clear() {List.clear();}
void resize(int i) {List.resize(i);}
2001-02-14 23:35:47 +01:00
void erase(int i) {List.erase(List.begin()+i);}
2001-02-16 19:23:01 +01:00
void insert(int i,T &Item) {List.insert(List.begin()+i,Item);}
2001-02-14 23:35:47 +01:00
// int begin() {return(List.begin);}
2000-12-06 20:29:40 +01:00
2000-12-02 19:55:49 +01:00
int size() {return(List.size());}
std::vector<T> &GetList() {return(List);}
T& operator []( int nIndex ) {return(List[nIndex]);}
private:
std::vector<T> List;
};
/*****************************************************************************/
#endif