89 lines
1.5 KiB
C++
89 lines
1.5 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
|
// = FileName : LoopList 模板类
|
|
// = Version : ver2.0
|
|
// = Author : zjq
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: LoopList 声明
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _LoopList_H_
|
|
#define _LoopList_H_
|
|
|
|
#ifndef _DLIST_H_
|
|
#include "DList.h"
|
|
#endif
|
|
|
|
#include "xglobalfunc.h"
|
|
|
|
template <class R>
|
|
class LoopList : public DList<R>
|
|
{
|
|
public:
|
|
|
|
LoopList();
|
|
~LoopList(){}
|
|
|
|
R * operator [](int n);
|
|
|
|
const R & operator [](int n) const;
|
|
|
|
|
|
const R & GetAt(int n) const;
|
|
R * GetAt(int n);
|
|
|
|
void RemoveNode(int n);
|
|
|
|
};
|
|
|
|
template <class R>
|
|
LoopList<R>::LoopList()
|
|
{
|
|
|
|
}
|
|
|
|
template <class R>
|
|
R * LoopList<R>::operator [](int n)
|
|
{
|
|
int nLen=this->Length();
|
|
n = XExport::LimitCycle(n, nLen);
|
|
return DList<R>::operator[](n);
|
|
}
|
|
|
|
template <class R>
|
|
const R & LoopList<R>::operator [](int n) const
|
|
{
|
|
int nLen=this->Length();
|
|
n = XExport::LimitCycle(n, nLen);
|
|
const DList<R> &rThis=*this;
|
|
return rThis[n];
|
|
}
|
|
|
|
template <class R>
|
|
R * LoopList<R>::GetAt(int n)
|
|
{
|
|
int nLen = this->Length();
|
|
n = XExport::LimitCycle(n, nLen);
|
|
return DList<R>::GetAt(n);
|
|
}
|
|
|
|
template <class R>
|
|
const R & LoopList<R>::GetAt(int n) const
|
|
{
|
|
int nLen = this->Length();
|
|
n = XExport::LimitCycle(n, nLen);
|
|
const DList<R> &rThis = *this;
|
|
return rThis.GetAt(n);
|
|
}
|
|
|
|
template <class R>
|
|
void LoopList<R>::RemoveNode(int n)
|
|
{
|
|
(*this)[n];
|
|
this->Remove();
|
|
}
|
|
|
|
|
|
#endif
|