Allow getting a ConstIterator from a non-const core:list
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3061 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
6eb1fa1e6e
commit
1a876af375
|
@ -1,5 +1,13 @@
|
|||
Changes in 1.7
|
||||
|
||||
- Allow getting a ConstIterator from a non-const core:list
|
||||
|
||||
- Add swap functions to irrMath and to the core classes.
|
||||
|
||||
- Deprecate map::isEmpty() and replace it with map::empty() to make it similar to other base classes.
|
||||
|
||||
- Allow to set the logging level already in SIrrlichtCreationParameters.
|
||||
|
||||
- Add clearSystemMessages to devices (implemented only for Linux and Win32 so far).
|
||||
|
||||
- Fix incorrect cursorpos for resizable windows on Windows Vista (found and patched by buffer)
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
T * operator ->() { return &Current->Element; }
|
||||
|
||||
private:
|
||||
Iterator(SKListNode* begin) : Current(begin) {}
|
||||
explicit Iterator(SKListNode* begin) : Current(begin) {}
|
||||
|
||||
SKListNode* Current;
|
||||
|
||||
|
@ -88,6 +88,7 @@ public:
|
|||
public:
|
||||
|
||||
ConstIterator() : Current(0) {}
|
||||
ConstIterator(const Iterator& iter) : Current(iter.Current) {}
|
||||
|
||||
ConstIterator& operator ++() { Current = Current->Next; return *this; }
|
||||
ConstIterator& operator --() { Current = Current->Prev; return *this; }
|
||||
|
@ -122,7 +123,7 @@ public:
|
|||
ConstIterator & operator =(const Iterator & iterator) { Current = iterator.Current; return *this; }
|
||||
|
||||
private:
|
||||
ConstIterator(SKListNode* begin) : Current(begin) {}
|
||||
explicit ConstIterator(SKListNode* begin) : Current(begin) {}
|
||||
|
||||
SKListNode* Current;
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ using namespace core;
|
|||
// list has no operator== currently so we have to check manually
|
||||
// TODO: Add an operator== to core::list and the kick this function out
|
||||
template <typename T>
|
||||
static bool compareLists(core::list<T> & a, core::list<T> & b)
|
||||
static bool compareLists(const core::list<T> & a, const core::list<T> & b)
|
||||
{
|
||||
if ( a.size() != b.size() )
|
||||
return false;
|
||||
// can't test allocator because we have no access to it here
|
||||
typename core::list<T>::Iterator iterA = a.begin(); // TODO: why can't we use ConstIterator here? Strange... this has to work!
|
||||
typename core::list<T>::Iterator iterB = b.begin();
|
||||
typename core::list<T>::ConstIterator iterA = a.begin();
|
||||
typename core::list<T>::ConstIterator iterB = b.begin();
|
||||
for ( ; iterA != a.end(); ++iterA, ++iterB )
|
||||
{
|
||||
if ( (*iterA) != (*iterB) )
|
||||
|
@ -23,6 +23,17 @@ static bool compareLists(core::list<T> & a, core::list<T> & b)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Make sure that we can get a const iterator from a non-const list
|
||||
template <typename T>
|
||||
static void constIteratorCompileTest(core::list<T> & a)
|
||||
{
|
||||
typename core::list<T>::ConstIterator iterA = a.begin();
|
||||
while (iterA != a.end() )
|
||||
{
|
||||
++iterA;
|
||||
}
|
||||
}
|
||||
|
||||
static bool testSwap()
|
||||
{
|
||||
bool result = true;
|
||||
|
@ -52,6 +63,9 @@ bool testIrrList(void)
|
|||
{
|
||||
bool success = true;
|
||||
|
||||
core::list<int> compileThisList;
|
||||
constIteratorCompileTest(compileThisList);
|
||||
|
||||
success &= testSwap();
|
||||
|
||||
if(success)
|
||||
|
|
Loading…
Reference in New Issue