📄 resarrayit.cpp
字号:
// ResArrayIt.cpp
//
// Author: Lea Hayes
// Date Created: 10/03/2006
// Date Modified: 10/03/2006
#include "Common.h"
#include "ResArrayIt.h"
using namespace Resources;
// ResArrayIt - Construction and deconstruction
ResArrayIt::ResArrayIt(LPRESLISTNODE pItem)
: ResArrayHandle(pItem)
{
}
ResArrayIt::ResArrayIt(const ResArrayIt &it)
: ResArrayHandle(it.m_pItem)
{
}
ResArrayIt::~ResArrayIt()
{
}
// ResArrayIt - Properties.
// Function Name: DistanceFrom
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: Calculate distance between this iterator and the
// iterator specified. When specified iterator occurs
// before this iterator a negative value is returned.
//
size_t ResArrayIt::DistanceFrom(const ResArrayIt &it)
{
// Simply return difference between iterator indexes.
return (**this)->GetIndex() -
(**const_cast<ResArrayIt*>(&it))->GetIndex();
}
// Function Name: Increment
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: Retrieve an iterator to the next resource(s).
//
void ResArrayIt::Increment(size_t nAmount /*=1*/)
{
// Increment iterator as specified.
for(size_t i = 0; i < nAmount; i++)
{
// Proceed to next item.
m_pItem = m_pItem->m_pNext;
}
}
// Function Name: Decrement
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: Retrieve an iterator to the previous resource(s).
//
void ResArrayIt::Decrement(size_t nAmount /*=1*/)
{
// Increment iterator as specified.
for(size_t i = 0; i < nAmount; i++)
{
// Proceed to previous item.
m_pItem = m_pItem->m_pPrev;
}
}
// ResArrayIt - Operator overloads.
// Function Name: operator+
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: Retrieve an iterator to the next resource.
//
ResArrayIt ResArrayIt::operator+ (size_t nAmount) const
{
// Resulting iterator to return.
ResArrayIt itResult = *this;
// Increment resulting iterator.
itResult.Increment(nAmount);
// Finally return the resulting iterator.
return itResult;
}
// Function Name: operator-
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: Retrieve an iterator to the previous resource.
//
ResArrayIt ResArrayIt::operator- (size_t nAmount) const
{
// Resulting iterator to return.
ResArrayIt itResult = *this;
// Decrement resulting iterator.
itResult.Decrement(nAmount);
// Finally return the resulting iterator.
return itResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -