made compatible with gcc 2.7.2

This commit is contained in:
Jeff Hill
2000-02-09 20:48:49 +00:00
parent 951df5f436
commit 3361eaa349
4 changed files with 70 additions and 42 deletions

View File

@@ -220,7 +220,11 @@ private:
// efficently. Hash indexes are produced more efficiently
// when (MAX_ID_WIDTH - MIN_INDEX_WIDTH) is minimized.
//
template <class T, unsigned MIN_INDEX_WIDTH = 4, unsigned MAX_ID_WIDTH = sizeof(T)*CHAR_BIT>
#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) )
template <class T, unsigned MIN_INDEX_WIDTH, unsigned MAX_ID_WIDTH>
#else
template <class T, unsigned MIN_INDEX_WIDTH=4, unsigned MAX_ID_WIDTH = sizeof(T)*CHAR_BIT>
#endif
class intId {
public:
intId (const T &idIn);
@@ -243,7 +247,11 @@ protected:
//
// NOTE: ITEM must public inherit from chronIntIdRes <ITEM>
//
#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) )
typedef intId<unsigned, 8, sizeof(unsigned)*CHAR_BIT> chronIntId;
#else
typedef intId<unsigned, 8> chronIntId;
#endif
template <class ITEM>
class chronIntIdResTable : public resTable<ITEM, chronIntId> {
public:

View File

@@ -11,10 +11,16 @@
void empty();
class albert : public intId<unsigned,8>, public tsSLNode<albert> {
#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) )
typedef intId<unsigned,8,16> testIntId;
#else
typedef intId<unsigned,8> testIntId;
#endif
class albert : public testIntId, public tsSLNode<albert> {
public:
albert (resTable< albert, intId<unsigned,8> > &atIn, unsigned idIn) :
intId<unsigned,8>(idIn), at(atIn)
albert (resTable< albert, testIntId > &atIn, unsigned idIn) :
testIntId(idIn), at(atIn)
{
assert (at.add (*this)==0);
}
@@ -27,13 +33,13 @@ public:
delete this;
}
private:
resTable< albert, intId<unsigned,8> > &at;
resTable< albert, testIntId > &at;
};
class fred : public intId<unsigned,8>, public tsSLNode<fred> {
class fred : public testIntId, public tsSLNode<fred> {
public:
fred (const char *pNameIn, unsigned idIn) :
intId<unsigned,8>(idIn), pName(pNameIn) {}
testIntId(idIn), pName(pNameIn) {}
void show (unsigned)
{
printf("fred %s\n", pName);
@@ -78,7 +84,7 @@ void jane::testTraverse()
// This explicitly instantiates the template class's member
// functions into "templInst.o"
//
template class resTable<fred,intId<unsigned,8> >;
template class resTable<fred,testIntId >;
template class resTable<jane,stringId>;
#endif
@@ -88,7 +94,7 @@ int main()
clock_t start, finish;
double duration;
const unsigned LOOPS = 50000;
resTable<fred, intId<unsigned,8> > intTbl (8);
resTable<fred, testIntId > intTbl (8);
resTable<jane, stringId> strTbl (8);
fred fred0("fred0",0);
fred fred1("fred1",0x1000a432);
@@ -104,16 +110,16 @@ int main()
jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
fred *pFred;
jane *pJane;
intId<unsigned,8> intId0 (0);
intId<unsigned,8> intId1 (0x1000a432);
intId<unsigned,8> intId2 (0x0000a432);
intId<unsigned,8> intId3 (1);
intId<unsigned,8> intId4 (2);
intId<unsigned,8> intId5 (3);
intId<unsigned,8> intId6 (4);
intId<unsigned,8> intId7 (5);
intId<unsigned,8> intId8 (6);
intId<unsigned,8> intId9 (7);
testIntId intId0 (0);
testIntId intId1 (0x1000a432);
testIntId intId2 (0x0000a432);
testIntId intId3 (1);
testIntId intId4 (2);
testIntId intId5 (3);
testIntId intId6 (4);
testIntId intId7 (5);
testIntId intId8 (6);
testIntId intId9 (7);
stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
@@ -235,7 +241,7 @@ int main()
// hash distribution test
//
static const unsigned tableSize = 0x1000;
resTable< albert, intId<unsigned,8> > alTbl (tableSize);
resTable< albert, testIntId > alTbl (tableSize);
for (i=0; i<tableSize*8; i++) {
albert *pa = new albert (alTbl, i);
@@ -243,7 +249,7 @@ int main()
}
alTbl.show(1u);
resTableIter< albert, intId<unsigned,8> > alTblIter (alTbl);
resTableIter< albert, testIntId > alTblIter (alTbl);
albert *pa;
i=0;
while ( (pa = alTblIter.next()) ) {

View File

@@ -220,7 +220,11 @@ private:
// efficently. Hash indexes are produced more efficiently
// when (MAX_ID_WIDTH - MIN_INDEX_WIDTH) is minimized.
//
template <class T, unsigned MIN_INDEX_WIDTH = 4, unsigned MAX_ID_WIDTH = sizeof(T)*CHAR_BIT>
#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) )
template <class T, unsigned MIN_INDEX_WIDTH, unsigned MAX_ID_WIDTH>
#else
template <class T, unsigned MIN_INDEX_WIDTH=4, unsigned MAX_ID_WIDTH = sizeof(T)*CHAR_BIT>
#endif
class intId {
public:
intId (const T &idIn);
@@ -243,7 +247,11 @@ protected:
//
// NOTE: ITEM must public inherit from chronIntIdRes <ITEM>
//
#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) )
typedef intId<unsigned, 8, sizeof(unsigned)*CHAR_BIT> chronIntId;
#else
typedef intId<unsigned, 8> chronIntId;
#endif
template <class ITEM>
class chronIntIdResTable : public resTable<ITEM, chronIntId> {
public:

View File

@@ -11,10 +11,16 @@
void empty();
class albert : public intId<unsigned,8>, public tsSLNode<albert> {
#if defined(__GNUC__) && ( __GNUC__<2 || (__GNUC__==2 && __GNUC__<8) )
typedef intId<unsigned,8,16> testIntId;
#else
typedef intId<unsigned,8> testIntId;
#endif
class albert : public testIntId, public tsSLNode<albert> {
public:
albert (resTable< albert, intId<unsigned,8> > &atIn, unsigned idIn) :
intId<unsigned,8>(idIn), at(atIn)
albert (resTable< albert, testIntId > &atIn, unsigned idIn) :
testIntId(idIn), at(atIn)
{
assert (at.add (*this)==0);
}
@@ -27,13 +33,13 @@ public:
delete this;
}
private:
resTable< albert, intId<unsigned,8> > &at;
resTable< albert, testIntId > &at;
};
class fred : public intId<unsigned,8>, public tsSLNode<fred> {
class fred : public testIntId, public tsSLNode<fred> {
public:
fred (const char *pNameIn, unsigned idIn) :
intId<unsigned,8>(idIn), pName(pNameIn) {}
testIntId(idIn), pName(pNameIn) {}
void show (unsigned)
{
printf("fred %s\n", pName);
@@ -78,7 +84,7 @@ void jane::testTraverse()
// This explicitly instantiates the template class's member
// functions into "templInst.o"
//
template class resTable<fred,intId<unsigned,8> >;
template class resTable<fred,testIntId >;
template class resTable<jane,stringId>;
#endif
@@ -88,7 +94,7 @@ int main()
clock_t start, finish;
double duration;
const unsigned LOOPS = 50000;
resTable<fred, intId<unsigned,8> > intTbl (8);
resTable<fred, testIntId > intTbl (8);
resTable<jane, stringId> strTbl (8);
fred fred0("fred0",0);
fred fred1("fred1",0x1000a432);
@@ -104,16 +110,16 @@ int main()
jane jane2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
fred *pFred;
jane *pJane;
intId<unsigned,8> intId0 (0);
intId<unsigned,8> intId1 (0x1000a432);
intId<unsigned,8> intId2 (0x0000a432);
intId<unsigned,8> intId3 (1);
intId<unsigned,8> intId4 (2);
intId<unsigned,8> intId5 (3);
intId<unsigned,8> intId6 (4);
intId<unsigned,8> intId7 (5);
intId<unsigned,8> intId8 (6);
intId<unsigned,8> intId9 (7);
testIntId intId0 (0);
testIntId intId1 (0x1000a432);
testIntId intId2 (0x0000a432);
testIntId intId3 (1);
testIntId intId4 (2);
testIntId intId5 (3);
testIntId intId6 (4);
testIntId intId7 (5);
testIntId intId8 (6);
testIntId intId9 (7);
stringId strId1("rrrrrrrrrrrrrrrrrrrrrrrrrr1");
stringId strId2("rrrrrrrrrrrrrrrrrrrrrrrrrr2");
@@ -235,7 +241,7 @@ int main()
// hash distribution test
//
static const unsigned tableSize = 0x1000;
resTable< albert, intId<unsigned,8> > alTbl (tableSize);
resTable< albert, testIntId > alTbl (tableSize);
for (i=0; i<tableSize*8; i++) {
albert *pa = new albert (alTbl, i);
@@ -243,7 +249,7 @@ int main()
}
alTbl.show(1u);
resTableIter< albert, intId<unsigned,8> > alTblIter (alTbl);
resTableIter< albert, testIntId > alTblIter (alTbl);
albert *pa;
i=0;
while ( (pa = alTblIter.next()) ) {