wwtsanmao 发表于 2009-12-21 16:42:00

list2.h

/*########################*/
//int Count()
//返回链表成员个数
/*########################*/
int Count() const
{
return numofUnit;
}
/*########################*/
//void Show()
//打印所有成员
/*########################*/
void Show() const
{
for (int i = 0;i < Count();i++)
{
   PRINT(Get(i));
}
PRINT("----------------");
return;
}
/*########################*/
//T First()
//返回链表中第一个成员
/*########################*/
T First() const
{
freep = 0;
return Get(freep++);
}
/*########################*/
//T Next()
//返回链表中第一个成员
/*########################*/
T Next()const
{
if (freep >= numofUnit)
{
   SLOP_OVER_INOF;
   freep = numofUnit - 1;
}
return Get(freep++);
}
/*########################*/
//bool Set (const T& _value,int _pos)
//修改成员的值
/*########################*/
bool Set (const T& _value,int _pos)const
{
if(_pos >= numofUnit || _pos < 0)
{
   return false;
}
units = _value;
return true;
}
/*########################*/
//bool Remove (int _pos)
//删除成员,成功返回true,失败返回false
/*########################*/
bool Remove (int _pos)
{
if(_pos >= numofUnit || _pos < 0)
{
   return false;
}

CopyElements(&units, &units, (sizeof(T) * (numofUnit - _pos - 1)));
numofUnit--;
return true;
}
/*########################*/
//void Close()
//清空链表中所有成员
/*########################*/
void Close()
{
for (int i = (Count() - 1);i >= 0;i--)
{
   Remove(i);
}
Reset();
return;
}

/*########################*/
//降序排列
/*########################*/
virtual void Sort () = 0;
/*########################*/
//升序排列
/*########################*/
virtual void VSort () = 0;
/*########################*/
//查找成员位置的纯虚函数,找到返回成员下标,找不到返回-1
/*########################*/
virtual int Find (const T& _value) = 0;

};

#endif
页: [1]
查看完整版本: list2.h