Files
envi-code/SourceCode/Code2026/Dimension/SHLoopList.h
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

93 lines
1.2 KiB
C++

#pragma once
#include "superList.h"
template <class R>
class SHLoopList : public PtrList<R>
{
public:
SHLoopList();
~SHLoopList(){}
R * operator [](int n);
const R & operator [](int n) const;
const R & GetAt(int n) const;
R * GetAt(int n);
void RemoveNode(int n);
};
namespace
{
int LimitCycle(int n, int nLen)
{
if (n < 0)
{
n += nLen;
}
else if (n >= nLen)
{
n -= nLen;
}
else
{
return n;
}
return LimitCycle(n, nLen);
}
}
template <class R>
SHLoopList<R>::SHLoopList()
{
}
template <class R>
R * SHLoopList<R>::operator [](int n)
{
int nLen=this->Length();
n = LimitCycle(n, nLen);
return PtrList<R>::operator[](n);
}
template <class R>
const R & SHLoopList<R>::operator [](int n) const
{
int nLen=this->Length();
n = LimitCycle(n, nLen);
const PtrList<R> &rThis=*this;
return rThis[n];
}
template <class R>
R * SHLoopList<R>::GetAt(int n)
{
int nLen = this->Length();
n = LimitCycle(n, nLen);
return PtrList<R>::GetAt(n);
}
template <class R>
const R & SHLoopList<R>::GetAt(int n) const
{
int nLen = this->Length();
n = LimitCycle(n, nLen);
const PtrList<R> &rThis = *this;
return rThis.GetAt(n);
}
template <class R>
void SHLoopList<R>::RemoveNode(int n)
{
(*this)[n];
this->Remove();
}