turn off exceptions for all versions of vxWorks andd allow iterators to be copied
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "tsSLList.h"
|
||||
#include "shareLib.h"
|
||||
@@ -57,6 +58,8 @@
|
||||
typedef size_t resTableIndex;
|
||||
static const unsigned indexWidth = sizeof(resTableIndex)*CHAR_BIT;
|
||||
|
||||
template <class T, class ID> class resTableIter;
|
||||
|
||||
//
|
||||
// class resTable <T, ID>
|
||||
//
|
||||
@@ -103,8 +106,16 @@ static const unsigned indexWidth = sizeof(resTableIndex)*CHAR_BIT;
|
||||
//
|
||||
template <class T, class ID>
|
||||
class resTable {
|
||||
friend class resTableIter<T,ID>;
|
||||
public:
|
||||
|
||||
//
|
||||
// exceptions thrown
|
||||
//
|
||||
class epicsShareClass dynamicMemoryAllocationFailed {};
|
||||
class epicsShareClass entryDidntRespondToDestroyVirtualFunction {};
|
||||
class epicsShareClass sizeExceedsMaxIndexWidth {};
|
||||
|
||||
resTable (unsigned nHashTableEntries);
|
||||
|
||||
virtual ~resTable();
|
||||
@@ -160,7 +171,7 @@ private:
|
||||
unsigned hashIdNBits;
|
||||
unsigned nInUse;
|
||||
|
||||
resTableIndex hash(const ID & idIn) const;
|
||||
resTableIndex hash (const ID & idIn) const;
|
||||
|
||||
T *find (tsSLList<T> &list, const ID &idIn) const;
|
||||
|
||||
@@ -171,6 +182,23 @@ private:
|
||||
// Some ID classes that work with the above template
|
||||
//
|
||||
|
||||
//
|
||||
// class resTableIter
|
||||
//
|
||||
// an iterator for the resource table class
|
||||
//
|
||||
template <class T, class ID>
|
||||
class resTableIter {
|
||||
public:
|
||||
resTableIter (const resTable<T,ID> &tableIn);
|
||||
T * next ();
|
||||
T * operator () ();
|
||||
private:
|
||||
tsSLIter<T> iter;
|
||||
unsigned index;
|
||||
const resTable<T,ID> *pTable;
|
||||
};
|
||||
|
||||
//
|
||||
// class intId
|
||||
//
|
||||
@@ -250,6 +278,10 @@ private:
|
||||
class epicsShareClass stringId {
|
||||
public:
|
||||
|
||||
//
|
||||
// exceptions
|
||||
//
|
||||
class epicsShareClass dynamicMemoryAllocationFailed {};
|
||||
|
||||
enum allocationType {copyString, refString};
|
||||
|
||||
@@ -275,33 +307,6 @@ private:
|
||||
static const unsigned char fastHashPermutedIndexSpace[256];
|
||||
};
|
||||
|
||||
//
|
||||
// exceptions thrown by this library
|
||||
//
|
||||
class epicsShareClass resLib_resourceWithThatNameIsAlreadyInstalled
|
||||
{
|
||||
public:
|
||||
resLib_resourceWithThatNameIsAlreadyInstalled ();
|
||||
};
|
||||
|
||||
class epicsShareClass resLib_dynamicMemoryAllocationFailed
|
||||
{
|
||||
public:
|
||||
resLib_dynamicMemoryAllocationFailed ();
|
||||
};
|
||||
|
||||
class epicsShareClass resLib_entryDidntRespondToDestroyVirtualFunction
|
||||
{
|
||||
public:
|
||||
resLib_entryDidntRespondToDestroyVirtualFunction ();
|
||||
};
|
||||
|
||||
class epicsShareClass resLib_sizeExceedsMaxIndexWidth
|
||||
{
|
||||
public:
|
||||
resLib_sizeExceedsMaxIndexWidth ();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// resTable<class T, class ID> member functions
|
||||
/////////////////////////////////////////////////
|
||||
@@ -326,7 +331,11 @@ resTable<T,ID>::resTable (unsigned nHashTableEntries) :
|
||||
}
|
||||
|
||||
if ( nbits > ID::maxIndexBitWidth ) {
|
||||
throw resLib_sizeExceedsMaxIndexWidth ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw sizeExceedsMaxIndexWidth ();
|
||||
# endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -343,7 +352,11 @@ resTable<T,ID>::resTable (unsigned nHashTableEntries) :
|
||||
this->nInUse = 0u;
|
||||
this->pTable = new tsSLList<T> [1<<nbits];
|
||||
if (this->pTable==0) {
|
||||
throw resLib_dynamicMemoryAllocationFailed ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw dynamicMemoryAllocationFailed ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,8 +390,7 @@ inline T * resTable<T,ID>::lookup (const ID &idIn) const
|
||||
template <class T, class ID>
|
||||
inline resTableIndex resTable<T,ID>::hash (const ID & idIn) const
|
||||
{
|
||||
return idIn.hash(this->hashIdNBits)
|
||||
& this->hashIdMask;
|
||||
return idIn.hash (this->hashIdNBits) & this->hashIdMask;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -579,12 +591,54 @@ resTable<T,ID>::~resTable()
|
||||
if (this->pTable) {
|
||||
this->destroyAllEntries();
|
||||
if (this->nInUse != 0u) {
|
||||
throw resLib_entryDidntRespondToDestroyVirtualFunction ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw entryDidntRespondToDestroyVirtualFunction ();
|
||||
# endif
|
||||
}
|
||||
delete [] this->pTable;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// resTableIter<T,ID> member functions
|
||||
//////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// resTableIter<T,ID>::resTableIter ()
|
||||
//
|
||||
template <class T, class ID>
|
||||
inline resTableIter<T,ID>::resTableIter (const resTable<T,ID> &tableIn) :
|
||||
iter (tableIn.pTable[0]), index (1), pTable (&tableIn) {}
|
||||
|
||||
//
|
||||
// resTableIter<T,ID>::next ()
|
||||
//
|
||||
template <class T, class ID>
|
||||
inline T * resTableIter<T,ID>::next ()
|
||||
{
|
||||
T *pNext = this->iter.next();
|
||||
if (pNext) {
|
||||
return pNext;
|
||||
}
|
||||
if ( this->index >= (1u<<this->table.hashIdNBits) ) {
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
this->iter = tsSLIter<T> (this->pTable->pTable[this->index++]);
|
||||
return this->iter.next ();
|
||||
}
|
||||
|
||||
//
|
||||
// resTableIter<T,ID>::operator () ()
|
||||
//
|
||||
template <class T, class ID>
|
||||
inline T * resTableIter<T,ID>::operator () ()
|
||||
{
|
||||
return this->next ();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// chronIntIdResTable<ITEM> member functions
|
||||
//////////////////////////////////////////////
|
||||
@@ -771,7 +825,11 @@ stringId::stringId (const char * idIn, allocationType typeIn) :
|
||||
memcpy ((void *)this->pStr, idIn, nChars);
|
||||
}
|
||||
else {
|
||||
throw resLib_dynamicMemoryAllocationFailed ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw dynamicMemoryAllocationFailed ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -904,21 +962,6 @@ const unsigned char stringId::fastHashPermutedIndexSpace[256] = {
|
||||
134, 68, 93,183,241, 81,196, 49,192, 65,212, 94,203, 10,200, 47
|
||||
};
|
||||
|
||||
//
|
||||
// instantiate exceptions
|
||||
//
|
||||
resLib_resourceWithThatNameIsAlreadyInstalled::
|
||||
resLib_resourceWithThatNameIsAlreadyInstalled () {}
|
||||
|
||||
resLib_dynamicMemoryAllocationFailed::
|
||||
resLib_dynamicMemoryAllocationFailed () {}
|
||||
|
||||
resLib_entryDidntRespondToDestroyVirtualFunction::
|
||||
resLib_entryDidntRespondToDestroyVirtualFunction () {}
|
||||
|
||||
resLib_sizeExceedsMaxIndexWidth::
|
||||
resLib_sizeExceedsMaxIndexWidth () {}
|
||||
|
||||
#endif // if instantiateRecourceLib is defined
|
||||
|
||||
#endif // INCresourceLibh
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// tsBTreeRMRet
|
||||
@@ -99,7 +100,11 @@ private:
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw invalid_btCmp ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalid_btCmp ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// the hp compiler complains about parameterized friend
|
||||
// class that has not been declared without this?
|
||||
@@ -49,7 +51,7 @@ friend class tsSLIter<T>;
|
||||
friend class tsSLIterRm<T>;
|
||||
public:
|
||||
|
||||
tsSLNode();
|
||||
tsSLNode ();
|
||||
|
||||
void operator = (const tsSLNode<T> &) const;
|
||||
|
||||
@@ -97,7 +99,7 @@ public:
|
||||
|
||||
private:
|
||||
T *pCurrent;
|
||||
const tsSLList<T> &list;
|
||||
const tsSLList<T> *pList; // ptr allows cpy op
|
||||
};
|
||||
|
||||
//
|
||||
@@ -124,7 +126,7 @@ public:
|
||||
private:
|
||||
T *pPrevious;
|
||||
T *pCurrent;
|
||||
tsSLList<T> &list;
|
||||
tsSLList<T> *pList; // ptr allows cpy op
|
||||
};
|
||||
|
||||
//////////////////////////////////////////
|
||||
@@ -241,7 +243,7 @@ inline void tsSLList<T>::push(T &item)
|
||||
//
|
||||
template <class T>
|
||||
inline tsSLIter<T>::tsSLIter (const tsSLList<T> &listIn) :
|
||||
pCurrent (0), list (listIn) {}
|
||||
pCurrent (0), pList (&listIn) {}
|
||||
|
||||
//
|
||||
// tsSLIter<T>::next ()
|
||||
@@ -260,7 +262,7 @@ T * tsSLIter<T>::next ()
|
||||
this->pCurrent = pCurNode->pNext;
|
||||
}
|
||||
else {
|
||||
const tsSLNode<T> &first = this->list;
|
||||
const tsSLNode<T> &first = *this->pList;
|
||||
//
|
||||
// assume that we are starting (or restarting) at the
|
||||
// beginning of the list
|
||||
@@ -304,7 +306,7 @@ inline T * tsSLIter<T>::operator () ()
|
||||
//
|
||||
template <class T>
|
||||
inline tsSLIterRm<T>::tsSLIterRm (tsSLList<T> &listIn) :
|
||||
pPrevious (0), pCurrent (0), list (listIn) {}
|
||||
pPrevious (0), pCurrent (0), pList (&listIn) {}
|
||||
|
||||
|
||||
//
|
||||
@@ -325,7 +327,7 @@ T * tsSLIterRm<T>::next ()
|
||||
this->pCurrent = pCurNode->pNext;
|
||||
}
|
||||
else {
|
||||
const tsSLNode<T> &first = this->list;
|
||||
const tsSLNode<T> &first = *this->pList;
|
||||
//
|
||||
// assume that we are starting (or restarting) at the
|
||||
// beginning of the list
|
||||
@@ -363,20 +365,28 @@ template <class T>
|
||||
void tsSLIterRm<T>::remove ()
|
||||
{
|
||||
if (this->pCurrent==0) {
|
||||
throw noCurrentItemInIterator ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw noCurrentItemInIterator ();
|
||||
# endif
|
||||
}
|
||||
|
||||
tsSLNode<T> *pPrevNode;
|
||||
tsSLNode<T> *pCurNode = this->pCurrent;
|
||||
|
||||
if (this->pPrevious==0) {
|
||||
pPrevNode = &this->list;
|
||||
pPrevNode = this->pList;
|
||||
//
|
||||
// fail if it is an attempt to
|
||||
// delete twice without moving the iterator
|
||||
//
|
||||
if (pPrevNode->pNext != this->pCurrent) {
|
||||
throw noCurrentItemInIterator ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw noCurrentItemInIterator ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "tsSLList.h"
|
||||
#include "shareLib.h"
|
||||
@@ -57,6 +58,8 @@
|
||||
typedef size_t resTableIndex;
|
||||
static const unsigned indexWidth = sizeof(resTableIndex)*CHAR_BIT;
|
||||
|
||||
template <class T, class ID> class resTableIter;
|
||||
|
||||
//
|
||||
// class resTable <T, ID>
|
||||
//
|
||||
@@ -103,8 +106,16 @@ static const unsigned indexWidth = sizeof(resTableIndex)*CHAR_BIT;
|
||||
//
|
||||
template <class T, class ID>
|
||||
class resTable {
|
||||
friend class resTableIter<T,ID>;
|
||||
public:
|
||||
|
||||
//
|
||||
// exceptions thrown
|
||||
//
|
||||
class epicsShareClass dynamicMemoryAllocationFailed {};
|
||||
class epicsShareClass entryDidntRespondToDestroyVirtualFunction {};
|
||||
class epicsShareClass sizeExceedsMaxIndexWidth {};
|
||||
|
||||
resTable (unsigned nHashTableEntries);
|
||||
|
||||
virtual ~resTable();
|
||||
@@ -160,7 +171,7 @@ private:
|
||||
unsigned hashIdNBits;
|
||||
unsigned nInUse;
|
||||
|
||||
resTableIndex hash(const ID & idIn) const;
|
||||
resTableIndex hash (const ID & idIn) const;
|
||||
|
||||
T *find (tsSLList<T> &list, const ID &idIn) const;
|
||||
|
||||
@@ -171,6 +182,23 @@ private:
|
||||
// Some ID classes that work with the above template
|
||||
//
|
||||
|
||||
//
|
||||
// class resTableIter
|
||||
//
|
||||
// an iterator for the resource table class
|
||||
//
|
||||
template <class T, class ID>
|
||||
class resTableIter {
|
||||
public:
|
||||
resTableIter (const resTable<T,ID> &tableIn);
|
||||
T * next ();
|
||||
T * operator () ();
|
||||
private:
|
||||
tsSLIter<T> iter;
|
||||
unsigned index;
|
||||
const resTable<T,ID> *pTable;
|
||||
};
|
||||
|
||||
//
|
||||
// class intId
|
||||
//
|
||||
@@ -250,6 +278,10 @@ private:
|
||||
class epicsShareClass stringId {
|
||||
public:
|
||||
|
||||
//
|
||||
// exceptions
|
||||
//
|
||||
class epicsShareClass dynamicMemoryAllocationFailed {};
|
||||
|
||||
enum allocationType {copyString, refString};
|
||||
|
||||
@@ -275,33 +307,6 @@ private:
|
||||
static const unsigned char fastHashPermutedIndexSpace[256];
|
||||
};
|
||||
|
||||
//
|
||||
// exceptions thrown by this library
|
||||
//
|
||||
class epicsShareClass resLib_resourceWithThatNameIsAlreadyInstalled
|
||||
{
|
||||
public:
|
||||
resLib_resourceWithThatNameIsAlreadyInstalled ();
|
||||
};
|
||||
|
||||
class epicsShareClass resLib_dynamicMemoryAllocationFailed
|
||||
{
|
||||
public:
|
||||
resLib_dynamicMemoryAllocationFailed ();
|
||||
};
|
||||
|
||||
class epicsShareClass resLib_entryDidntRespondToDestroyVirtualFunction
|
||||
{
|
||||
public:
|
||||
resLib_entryDidntRespondToDestroyVirtualFunction ();
|
||||
};
|
||||
|
||||
class epicsShareClass resLib_sizeExceedsMaxIndexWidth
|
||||
{
|
||||
public:
|
||||
resLib_sizeExceedsMaxIndexWidth ();
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// resTable<class T, class ID> member functions
|
||||
/////////////////////////////////////////////////
|
||||
@@ -326,7 +331,11 @@ resTable<T,ID>::resTable (unsigned nHashTableEntries) :
|
||||
}
|
||||
|
||||
if ( nbits > ID::maxIndexBitWidth ) {
|
||||
throw resLib_sizeExceedsMaxIndexWidth ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw sizeExceedsMaxIndexWidth ();
|
||||
# endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -343,7 +352,11 @@ resTable<T,ID>::resTable (unsigned nHashTableEntries) :
|
||||
this->nInUse = 0u;
|
||||
this->pTable = new tsSLList<T> [1<<nbits];
|
||||
if (this->pTable==0) {
|
||||
throw resLib_dynamicMemoryAllocationFailed ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw dynamicMemoryAllocationFailed ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,8 +390,7 @@ inline T * resTable<T,ID>::lookup (const ID &idIn) const
|
||||
template <class T, class ID>
|
||||
inline resTableIndex resTable<T,ID>::hash (const ID & idIn) const
|
||||
{
|
||||
return idIn.hash(this->hashIdNBits)
|
||||
& this->hashIdMask;
|
||||
return idIn.hash (this->hashIdNBits) & this->hashIdMask;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -579,12 +591,54 @@ resTable<T,ID>::~resTable()
|
||||
if (this->pTable) {
|
||||
this->destroyAllEntries();
|
||||
if (this->nInUse != 0u) {
|
||||
throw resLib_entryDidntRespondToDestroyVirtualFunction ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw entryDidntRespondToDestroyVirtualFunction ();
|
||||
# endif
|
||||
}
|
||||
delete [] this->pTable;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// resTableIter<T,ID> member functions
|
||||
//////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// resTableIter<T,ID>::resTableIter ()
|
||||
//
|
||||
template <class T, class ID>
|
||||
inline resTableIter<T,ID>::resTableIter (const resTable<T,ID> &tableIn) :
|
||||
iter (tableIn.pTable[0]), index (1), pTable (&tableIn) {}
|
||||
|
||||
//
|
||||
// resTableIter<T,ID>::next ()
|
||||
//
|
||||
template <class T, class ID>
|
||||
inline T * resTableIter<T,ID>::next ()
|
||||
{
|
||||
T *pNext = this->iter.next();
|
||||
if (pNext) {
|
||||
return pNext;
|
||||
}
|
||||
if ( this->index >= (1u<<this->table.hashIdNBits) ) {
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
this->iter = tsSLIter<T> (this->pTable->pTable[this->index++]);
|
||||
return this->iter.next ();
|
||||
}
|
||||
|
||||
//
|
||||
// resTableIter<T,ID>::operator () ()
|
||||
//
|
||||
template <class T, class ID>
|
||||
inline T * resTableIter<T,ID>::operator () ()
|
||||
{
|
||||
return this->next ();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// chronIntIdResTable<ITEM> member functions
|
||||
//////////////////////////////////////////////
|
||||
@@ -771,7 +825,11 @@ stringId::stringId (const char * idIn, allocationType typeIn) :
|
||||
memcpy ((void *)this->pStr, idIn, nChars);
|
||||
}
|
||||
else {
|
||||
throw resLib_dynamicMemoryAllocationFailed ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw dynamicMemoryAllocationFailed ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -904,21 +962,6 @@ const unsigned char stringId::fastHashPermutedIndexSpace[256] = {
|
||||
134, 68, 93,183,241, 81,196, 49,192, 65,212, 94,203, 10,200, 47
|
||||
};
|
||||
|
||||
//
|
||||
// instantiate exceptions
|
||||
//
|
||||
resLib_resourceWithThatNameIsAlreadyInstalled::
|
||||
resLib_resourceWithThatNameIsAlreadyInstalled () {}
|
||||
|
||||
resLib_dynamicMemoryAllocationFailed::
|
||||
resLib_dynamicMemoryAllocationFailed () {}
|
||||
|
||||
resLib_entryDidntRespondToDestroyVirtualFunction::
|
||||
resLib_entryDidntRespondToDestroyVirtualFunction () {}
|
||||
|
||||
resLib_sizeExceedsMaxIndexWidth::
|
||||
resLib_sizeExceedsMaxIndexWidth () {}
|
||||
|
||||
#endif // if instantiateRecourceLib is defined
|
||||
|
||||
#endif // INCresourceLibh
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// tsBTreeRMRet
|
||||
@@ -99,7 +100,11 @@ private:
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw invalid_btCmp ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalid_btCmp ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
//
|
||||
// the hp compiler complains about parameterized friend
|
||||
// class that has not been declared without this?
|
||||
@@ -49,7 +51,7 @@ friend class tsSLIter<T>;
|
||||
friend class tsSLIterRm<T>;
|
||||
public:
|
||||
|
||||
tsSLNode();
|
||||
tsSLNode ();
|
||||
|
||||
void operator = (const tsSLNode<T> &) const;
|
||||
|
||||
@@ -97,7 +99,7 @@ public:
|
||||
|
||||
private:
|
||||
T *pCurrent;
|
||||
const tsSLList<T> &list;
|
||||
const tsSLList<T> *pList; // ptr allows cpy op
|
||||
};
|
||||
|
||||
//
|
||||
@@ -124,7 +126,7 @@ public:
|
||||
private:
|
||||
T *pPrevious;
|
||||
T *pCurrent;
|
||||
tsSLList<T> &list;
|
||||
tsSLList<T> *pList; // ptr allows cpy op
|
||||
};
|
||||
|
||||
//////////////////////////////////////////
|
||||
@@ -241,7 +243,7 @@ inline void tsSLList<T>::push(T &item)
|
||||
//
|
||||
template <class T>
|
||||
inline tsSLIter<T>::tsSLIter (const tsSLList<T> &listIn) :
|
||||
pCurrent (0), list (listIn) {}
|
||||
pCurrent (0), pList (&listIn) {}
|
||||
|
||||
//
|
||||
// tsSLIter<T>::next ()
|
||||
@@ -260,7 +262,7 @@ T * tsSLIter<T>::next ()
|
||||
this->pCurrent = pCurNode->pNext;
|
||||
}
|
||||
else {
|
||||
const tsSLNode<T> &first = this->list;
|
||||
const tsSLNode<T> &first = *this->pList;
|
||||
//
|
||||
// assume that we are starting (or restarting) at the
|
||||
// beginning of the list
|
||||
@@ -304,7 +306,7 @@ inline T * tsSLIter<T>::operator () ()
|
||||
//
|
||||
template <class T>
|
||||
inline tsSLIterRm<T>::tsSLIterRm (tsSLList<T> &listIn) :
|
||||
pPrevious (0), pCurrent (0), list (listIn) {}
|
||||
pPrevious (0), pCurrent (0), pList (&listIn) {}
|
||||
|
||||
|
||||
//
|
||||
@@ -325,7 +327,7 @@ T * tsSLIterRm<T>::next ()
|
||||
this->pCurrent = pCurNode->pNext;
|
||||
}
|
||||
else {
|
||||
const tsSLNode<T> &first = this->list;
|
||||
const tsSLNode<T> &first = *this->pList;
|
||||
//
|
||||
// assume that we are starting (or restarting) at the
|
||||
// beginning of the list
|
||||
@@ -363,20 +365,28 @@ template <class T>
|
||||
void tsSLIterRm<T>::remove ()
|
||||
{
|
||||
if (this->pCurrent==0) {
|
||||
throw noCurrentItemInIterator ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw noCurrentItemInIterator ();
|
||||
# endif
|
||||
}
|
||||
|
||||
tsSLNode<T> *pPrevNode;
|
||||
tsSLNode<T> *pCurNode = this->pCurrent;
|
||||
|
||||
if (this->pPrevious==0) {
|
||||
pPrevNode = &this->list;
|
||||
pPrevNode = this->pList;
|
||||
//
|
||||
// fail if it is an attempt to
|
||||
// delete twice without moving the iterator
|
||||
//
|
||||
if (pPrevNode->pNext != this->pCurrent) {
|
||||
throw noCurrentItemInIterator ();
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw noCurrentItemInIterator ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user