Path: blob/devel/ElmerGUI/netgen/libsrc/general/hashtabl.hpp
3206 views
#ifndef FILE_HASHTABL1#define FILE_HASHTABL23/**************************************************************************/4/* File: hashtabl.hh */5/* Author: Joachim Schoeberl */6/* Date: 01. Jun. 95 */7/**************************************************************************/89/**10Abstract data type HASHTABLE.11Hash is done by one INDEX12*/13class BASE_INDEX_HASHTABLE14{15protected:16/// keys are stored in this table17TABLE<INDEX> hash;1819public:20///21BASE_INDEX_HASHTABLE (int size)22: hash (size) { };2324protected:25///26int HashValue (const INDEX & ind) const27{28return ind % hash.Size() + 1;29}3031///32int Position (int bnr, const INDEX & ind) const;33};3435///36template <class T>37class INDEX_HASHTABLE : private BASE_INDEX_HASHTABLE38{39///40TABLE<T> cont;4142public:43///44inline INDEX_HASHTABLE (int size);45///46inline void Set (const INDEX & hash, const T & acont);47///48inline const T & Get (const INDEX & ahash) const;49///50inline bool Used (const INDEX & ahash) const;51///52inline int GetNBags () const;53///54inline int GetBagSize (int bnr) const;55///56inline void GetData (int bnr, int colnr, INDEX & ahash, T & acont) const;5758///59inline void PrintMemInfo (ostream & ost) const;60};616263646566676869707172///73class BASE_INDEX_2_HASHTABLE74{75protected:76///77TABLE<INDEX_2> hash;7879public:80///81BASE_INDEX_2_HASHTABLE (int size)82: hash (size) { };8384///85void PrintStat (ostream & ost) const;86void BaseSetSize(int s) {hash.SetSize(s);}87protected:88///89int HashValue (const INDEX_2 & ind) const90{91return (ind.I1() + ind.I2()) % hash.Size() + 1;92}93///94int Position (int bnr, const INDEX_2 & ind) const95{96int i;97for (i = 1; i <= hash.EntrySize (bnr); i++)98if (hash.Get(bnr, i) == ind)99return i;100return 0;101}102};103104105///106template <class T>107class INDEX_2_HASHTABLE : public BASE_INDEX_2_HASHTABLE108{109///110TABLE<T> cont;111112public:113///114INDEX_2_HASHTABLE (int size)115: BASE_INDEX_2_HASHTABLE (size), cont(size)116{ ; }117118///119void SetSize(int s)120{121cont.SetSize(s);122BaseSetSize(s);123}124125///126void Set (const INDEX_2 & ahash, const T & acont)127{128int bnr = HashValue (ahash);129int pos = Position (bnr, ahash);130if (pos)131cont.Set (bnr, pos, acont);132else133{134hash.Add1 (bnr, ahash);135cont.Add1 (bnr, acont);136}137}138139///140const T & Get (const INDEX_2 & ahash) const141{142int bnr = HashValue (ahash);143int pos = Position (bnr, ahash);144return cont.Get (bnr, pos);145}146147///148bool Used (const INDEX_2 & ahash) const149{150return (Position (HashValue (ahash), ahash)) ? 1 : 0;151}152///153int GetNBags () const154{155return cont.Size();156}157158///159int GetBagSize (int bnr) const160{161return cont.EntrySize (bnr);162}163164///165void GetData (int bnr, int colnr,166INDEX_2 & ahash, T & acont) const167{168ahash = hash.Get(bnr, colnr);169acont = cont.Get(bnr, colnr);170}171172///173void SetData (int bnr, int colnr,174const INDEX_2 & ahash, const T & acont)175{176hash.Set(bnr, colnr, ahash);177cont.Set(bnr, colnr, acont);178}179180///181void PrintMemInfo (ostream & ost) const182{183ost << "Hash: " << endl;184hash.PrintMemInfo (ost);185ost << "Cont: " << endl;186cont.PrintMemInfo (ost);187}188189190void DeleteData ()191{192int n = hash.Size();193hash.SetSize (n);194cont.SetSize (n);195}196197198class Iterator199{200const INDEX_2_HASHTABLE & ht;201int bagnr, pos;202public:203Iterator (const INDEX_2_HASHTABLE & aht,204int abagnr, int apos)205: ht(aht), bagnr(abagnr), pos(apos)206{ ; }207208int BagNr() const { return bagnr; }209int Pos() const { return pos; }210211void operator++ (int)212{213// cout << "begin Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;214pos++;215while (bagnr < ht.GetNBags() &&216pos == ht.GetBagSize(bagnr+1))217{218pos = 0;219bagnr++;220}221// cout << "end Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;222}223224bool operator != (int i) const225{226return bagnr != i;227}228229};230231Iterator Begin () const232{233Iterator it(*this, 0, -1);234it++;235return it;236}237238int End() const239{240return GetNBags();241}242243void GetData (const Iterator & it,244INDEX_2 & ahash, T & acont) const245{246ahash = hash[it.BagNr()][it.Pos()];247acont = cont[it.BagNr()][it.Pos()];248}249250const INDEX_2 & GetHash (const Iterator & it) const251{ return hash[it.BagNr()][it.Pos()]; }252253const T & GetData (const Iterator & it) const254{ return cont[it.BagNr()][it.Pos()]; }255};256257258259template <typename T>260inline ostream & operator<< (ostream & ost, const INDEX_2_HASHTABLE<T> & ht)261{262for (typename INDEX_2_HASHTABLE<T>::Iterator it = ht.Begin();263it != ht.End(); it++)264{265ost << ht.GetHash(it) << ": " << ht.GetData(it) << endl;266}267268return ost;269}270271272273274275276277///278class BASE_INDEX_3_HASHTABLE279{280protected:281///282TABLE<INDEX_3> hash;283284public:285///286BASE_INDEX_3_HASHTABLE (int size)287: hash (size) { };288289protected:290///291int HashValue (const INDEX_3 & ind) const292{293return (ind.I1() + ind.I2() + ind.I3()) % hash.Size() + 1;294}295296///297int Position (int bnr, const INDEX_3 & ind) const298{299const INDEX_3 * pi = &hash.Get(bnr, 1);300int n = hash.EntrySize(bnr);301for (int i = 1; i <= n; ++i, ++pi)302{303if (*pi == ind)304return i;305}306307return 0;308}309310311};312313314///315template <class T>316class INDEX_3_HASHTABLE : private BASE_INDEX_3_HASHTABLE317{318///319TABLE<T> cont;320321public:322///323inline INDEX_3_HASHTABLE (int size);324///325inline void Set (const INDEX_3 & ahash, const T & acont);326///327inline const T & Get (const INDEX_3 & ahash) const;328///329inline bool Used (const INDEX_3 & ahash) const;330///331inline int GetNBags () const;332///333inline int GetBagSize (int bnr) const;334///335inline void SetData (int bnr, int colnr, const INDEX_3 & ahash, const T & acont);336///337inline void GetData (int bnr, int colnr, INDEX_3 & ahash, T & acont) const;338/// returns position, if not existing, will create (create == return 1)339inline int PositionCreate (const INDEX_3 & ahash, int & bnr, int & colnr);340///341inline void SetSize (int size);342343///344inline void PrepareSet (const INDEX_3 & ahash);345///346inline void AllocateElements ();347348///349inline void PrintMemInfo (ostream & ost) const;350///351inline void DeleteData ();352353354355356357358359360361class Iterator362{363const INDEX_3_HASHTABLE & ht;364int bagnr, pos;365public:366Iterator (const INDEX_3_HASHTABLE & aht,367int abagnr, int apos)368: ht(aht), bagnr(abagnr), pos(apos)369{ ; }370371int BagNr() const { return bagnr; }372int Pos() const { return pos; }373374void operator++ (int)375{376// cout << "begin Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;377pos++;378while (bagnr < ht.GetNBags() &&379pos == ht.GetBagSize(bagnr+1))380{381pos = 0;382bagnr++;383}384// cout << "end Operator ++: bagnr = " << bagnr << " - pos = " << pos << endl;385}386387bool operator != (int i) const388{389return bagnr != i;390}391392};393394Iterator Begin () const395{396Iterator it(*this, 0, -1);397it++;398return it;399}400401int End() const402{403return GetNBags();404}405406void GetData (const Iterator & it,407INDEX_3 & ahash, T & acont) const408{409ahash = hash[it.BagNr()][it.Pos()];410acont = cont[it.BagNr()][it.Pos()];411}412413const INDEX_3 & GetHash (const Iterator & it) const414{ return hash[it.BagNr()][it.Pos()]; }415416const T & GetData (const Iterator & it) const417{ return cont[it.BagNr()][it.Pos()]; }418419420421};422423424425426427428template <typename T>429inline ostream & operator<< (ostream & ost, const INDEX_3_HASHTABLE<T> & ht)430{431for (typename INDEX_3_HASHTABLE<T>::Iterator it = ht.Begin();432it != ht.End(); it++)433{434ost << ht.GetHash(it) << ": " << ht.GetData(it) << endl;435}436437return ost;438}439440441442443444445446447448449450451452453454455456457458459460461462463/// Closed Hashing HT464465class BASE_INDEX_CLOSED_HASHTABLE466{467protected:468///469MoveableArray<INDEX> hash;470///471int invalid;472public:473///474BASE_INDEX_CLOSED_HASHTABLE (int size);475476int Size() const { return hash.Size(); }477int UsedPos (int pos) const { return ! (hash.Get(pos) == invalid); }478int UsedElements () const;479480///481int HashValue (const INDEX & ind) const482{483return ind % hash.Size() + 1;484}485486487int Position (const INDEX & ind) const488{489int i = HashValue(ind);490while (1)491{492if (hash.Get(i) == ind) return i;493if (hash.Get(i) == invalid) return 0;494i++;495if (i > hash.Size()) i = 1;496}497}498499// returns 1, if new postion is created500int PositionCreate (const INDEX & ind, int & apos)501{502int i = HashValue (ind);503if (hash.Get(i) == ind)504{505apos = i;506return 0;507}508if (hash.Get(i) == invalid)509{510hash.Elem(i) = ind;511apos = i;512return 1;513}514return PositionCreate2 (ind, apos);515}516517protected:518int Position2 (const INDEX & ind) const;519int PositionCreate2 (const INDEX & ind, int & apos);520void BaseSetSize (int asize);521};522523524template <class T>525class INDEX_CLOSED_HASHTABLE : public BASE_INDEX_CLOSED_HASHTABLE526{527///528MoveableArray<T> cont;529530public:531///532INDEX_CLOSED_HASHTABLE (int size)533: BASE_INDEX_CLOSED_HASHTABLE(size), cont(size)534{535cont.SetName ("ind-hashtable, contents");536}537538539void Set (const INDEX & ahash, const T & acont)540{541int pos;542PositionCreate (ahash, pos);543hash.Elem(pos) = ahash;544cont.Elem(pos) = acont;545}546547const T & Get (const INDEX & ahash) const548{549int pos = Position (ahash);550return cont.Get(pos);551}552553///554bool Used (const INDEX & ahash) const555{556int pos = Position (ahash);557return (pos != 0);558}559560561///562inline void SetData (int pos, const INDEX & ahash, const T & acont)563{564hash.Elem(pos) = ahash;565cont.Elem(pos) = acont;566}567568///569void GetData (int pos, INDEX & ahash, T & acont) const570{571ahash = hash.Get(pos);572acont = cont.Get(pos);573}574575///576inline void SetData (int pos, const T & acont)577{578cont.Elem(pos) = acont;579}580581///582void GetData (int pos, T & acont) const583{584acont = cont.Get(pos);585}586587///588const T & GetData (int pos) { return cont.Get(pos); }589///590inline void SetSize (int size)591{592BaseSetSize(size);593cont.SetSize(size);594}595596///597inline void DeleteData ()598{ SetSize (cont.Size()); }599600void SetName (const char * aname)601{602cont.SetName(aname);603hash.SetName(aname);604}605};606607608609610611612613/// Closed Hashing HT614615class BASE_INDEX_2_CLOSED_HASHTABLE616{617protected:618///619MoveableArray<INDEX_2> hash;620///621int invalid;622public:623///624BASE_INDEX_2_CLOSED_HASHTABLE (int size);625626int Size() const { return hash.Size(); }627int UsedPos (int pos) const { return ! (hash.Get(pos).I1() == invalid); }628int UsedElements () const;629630///631int HashValue (const INDEX_2 & ind) const632{633return (ind.I1() + 71 * ind.I2()) % hash.Size() + 1;634}635636637int Position (const INDEX_2 & ind) const638{639int i = HashValue(ind);640while (1)641{642if (hash.Get(i) == ind) return i;643if (hash.Get(i).I1() == invalid) return 0;644i++;645if (i > hash.Size()) i = 1;646}647}648649// returns 1, if new postion is created650int PositionCreate (const INDEX_2 & ind, int & apos)651{652int i = HashValue (ind);653if (hash.Get(i) == ind)654{655apos = i;656return 0;657}658if (hash.Get(i).I1() == invalid)659{660hash.Elem(i) = ind;661apos = i;662return 1;663}664return PositionCreate2 (ind, apos);665}666667protected:668///669670int Position2 (const INDEX_2 & ind) const;671int PositionCreate2 (const INDEX_2 & ind, int & apos);672void BaseSetSize (int asize);673};674675676template <class T>677class INDEX_2_CLOSED_HASHTABLE : public BASE_INDEX_2_CLOSED_HASHTABLE678{679///680MoveableArray<T> cont;681682public:683///684inline INDEX_2_CLOSED_HASHTABLE (int size);685///686inline void Set (const INDEX_2 & ahash, const T & acont);687///688inline const T & Get (const INDEX_2 & ahash) const;689///690inline bool Used (const INDEX_2 & ahash) const;691///692inline void SetData (int pos, const INDEX_2 & ahash, const T & acont);693///694inline void GetData (int pos, INDEX_2 & ahash, T & acont) const;695///696inline void SetData (int pos, const T & acont);697///698inline void GetData (int pos, T & acont) const;699///700const T & GetData (int pos) { return cont.Get(pos); }701///702inline void SetSize (int size);703///704inline void PrintMemInfo (ostream & ost) const;705///706inline void DeleteData ()707{ SetSize (cont.Size()); }708709void SetName (const char * aname)710{711cont.SetName(aname);712hash.SetName(aname);713}714};715716class BASE_INDEX_3_CLOSED_HASHTABLE717{718protected:719MoveableArray<INDEX_3> hash;720int invalid;721722protected:723// public: //SZ724BASE_INDEX_3_CLOSED_HASHTABLE (int size)725: hash(size)726{727hash.SetName ("i3-hashtable, hash");728invalid = -1;729for (int i = 0; i < size; i++)730hash[i].I1() = invalid;731}732733public:734int Size() const735{736return hash.Size();737}738739bool UsedPos (int pos) const740{741return ! (hash[pos].I1() == invalid);742}743744int UsedElements () const745{746int n = hash.Size();747int cnt = 0;748for (int i = 0; i < n; i++)749if (hash[i].I1() != invalid)750cnt++;751return cnt;752}753754int HashValue (const INDEX_3 & ind) const755{756return (ind.I1() + 15 * ind.I2() + 41 * ind.I3()) % hash.Size();757}758759int Position (const INDEX_3 & ind) const760{761int i = HashValue(ind);762while (1)763{764if (hash[i] == ind) return i;765if (hash[i].I1() == invalid) return -1;766i = (i+1) % hash.Size();767}768}769770int Costs (const INDEX_3 & ind) const771{772int i = HashValue(ind);773int c = 1;774while (1)775{776if (hash[i] == ind) return c;777if (hash[i].I1() == invalid) return c;778i = (i+1) % hash.Size();779c++;780}781}782783784785// returns true, if new postion is created786bool PositionCreate (const INDEX_3 & ind, int & apos)787{788int i = HashValue (ind);789if (hash[i] == ind)790{791apos = i;792return false;793}794if (hash[i].I1() == invalid)795{796hash[i] = ind;797apos = i;798return true;799}800return PositionCreate2 (ind, apos);801}802803protected:804bool PositionCreate2 (const INDEX_3 & ind, int & apos);805void BaseSetSize (int asize);806};807808809810template <class T>811class INDEX_3_CLOSED_HASHTABLE : public BASE_INDEX_3_CLOSED_HASHTABLE812{813MoveableArray<T,0> cont;814815public:816INDEX_3_CLOSED_HASHTABLE (int size)817: BASE_INDEX_3_CLOSED_HASHTABLE(size), cont(size)818{819cont.SetName ("i3-hashtable, contents");820}821822void Set (const INDEX_3 & ahash, const T & acont)823{824int pos;825PositionCreate (ahash, pos);826hash[pos] = ahash;827cont[pos] = acont;828}829830const T & Get (const INDEX_3 & ahash) const831{832return cont[Position (ahash)];833}834835bool Used (const INDEX_3 & ahash) const836{837return (Position (ahash) != -1);838}839840void SetData (int pos, const INDEX_3 & ahash, const T & acont)841{842hash[pos] = ahash;843cont[pos] = acont;844}845846void GetData (int pos, INDEX_3 & ahash, T & acont) const847{848ahash = hash[pos];849acont = cont[pos];850}851852void SetData (int pos, const T & acont)853{854cont[pos] = acont;855}856857void GetData (int pos, T & acont) const858{859acont = cont[pos];860}861862const T & GetData (int pos) const863{864return cont[pos];865}866867void SetSize (int size)868{869BaseSetSize(size);870cont.SetSize(size);871}872873void PrintMemInfo (ostream & ost) const874{875cout << "Hashtable: " << Size()876<< " entries of size " << sizeof(INDEX_3) << " + " << sizeof(T)877<< " = " << Size() * (sizeof(INDEX_3) + sizeof(T)) << " bytes" << endl;878879}880881void DeleteData ()882{883SetSize (cont.Size());884}885886void SetName (const char * aname)887{888cont.SetName(aname);889hash.SetName(aname);890}891};892893894895896897898899900901902903904905906907908909template<class T>910inline INDEX_3_HASHTABLE<T> :: INDEX_3_HASHTABLE (int size)911: BASE_INDEX_3_HASHTABLE (size), cont(size)912{913;914}915916template<class T>917inline int INDEX_3_HASHTABLE<T> :: PositionCreate (const INDEX_3 & ahash, int & bnr, int & colnr)918{919bnr = HashValue (ahash);920colnr = Position (bnr, ahash);921if (!colnr)922{923hash.Add (bnr, ahash);924cont.AddEmpty (bnr);925colnr = cont.EntrySize (bnr);926return 1;927}928return 0;929}930931932template<class T>933inline void INDEX_3_HASHTABLE<T> :: Set (const INDEX_3 & ahash, const T & acont)934{935int bnr = HashValue (ahash);936int pos = Position (bnr, ahash);937if (pos)938cont.Set (bnr, pos, acont);939else940{941hash.Add1 (bnr, ahash);942cont.Add1 (bnr, acont);943}944}945946template<class T>947inline const T & INDEX_3_HASHTABLE<T> :: Get (const INDEX_3 & ahash) const948{949int bnr = HashValue (ahash);950int pos = Position (bnr, ahash);951return cont.Get (bnr, pos);952}953954template<class T>955inline bool INDEX_3_HASHTABLE<T> :: Used (const INDEX_3 & ahash) const956{957return (Position (HashValue (ahash), ahash)) ? 1 : 0;958}959960template<class T>961inline int INDEX_3_HASHTABLE<T> :: GetNBags () const962{963return cont.Size();964}965966template<class T>967inline int INDEX_3_HASHTABLE<T> :: GetBagSize (int bnr) const968{969return cont.EntrySize (bnr);970}971972template<class T>973inline void INDEX_3_HASHTABLE<T> :: GetData (int bnr, int colnr, INDEX_3 & ahash, T & acont) const974{975ahash = hash.Get(bnr, colnr);976acont = cont.Get(bnr, colnr);977}978979template<class T>980inline void INDEX_3_HASHTABLE<T> :: SetData (int bnr, int colnr, const INDEX_3 & ahash, const T & acont)981{982hash.Set(bnr, colnr, ahash);983cont.Set(bnr, colnr, acont);984}985986template<class T>987inline void INDEX_3_HASHTABLE<T> :: SetSize (int size)988{989hash.SetSize (size);990cont.SetSize (size);991}992993template<class T>994inline void INDEX_3_HASHTABLE<T> :: DeleteData ()995{996int n = hash.Size();997hash.SetSize (n);998cont.SetSize (n);999}10001001template<class T>1002inline void INDEX_3_HASHTABLE<T> :: PrepareSet (const INDEX_3 & ahash)1003{1004int bnr = HashValue (ahash);1005hash.IncSizePrepare (bnr-1);1006cont.IncSizePrepare (bnr-1);1007}100810091010template<class T>1011inline void INDEX_3_HASHTABLE<T> :: AllocateElements ()1012{1013hash.AllocateElementsOneBlock();1014cont.AllocateElementsOneBlock();1015}1016101710181019template<class T>1020inline void INDEX_3_HASHTABLE<T> :: PrintMemInfo (ostream & ost) const1021{1022ost << "Hash: " << endl;1023hash.PrintMemInfo (ost);1024ost << "Cont: " << endl;1025cont.PrintMemInfo (ost);1026}102710281029103010311032template<class T>1033inline INDEX_HASHTABLE<T> :: INDEX_HASHTABLE (int size)1034: BASE_INDEX_HASHTABLE (size), cont(size)1035{1036;1037}10381039template<class T>1040inline void INDEX_HASHTABLE<T> :: Set (const INDEX & ahash, const T & acont)1041{1042int bnr = HashValue (ahash);1043int pos = Position (bnr, ahash);1044if (pos)1045cont.Set (bnr, pos, acont);1046else1047{1048hash.Add (bnr, ahash);1049cont.Add (bnr, acont);1050}1051}10521053template<class T>1054inline const T & INDEX_HASHTABLE<T> :: Get (const INDEX & ahash) const1055{1056int bnr = HashValue (ahash);1057int pos = Position (bnr, ahash);1058return cont.Get (bnr, pos);1059}10601061template<class T>1062inline bool INDEX_HASHTABLE<T> :: Used (const INDEX & ahash) const1063{1064return (Position (HashValue (ahash), ahash)) ? 1 : 0;1065}10661067template<class T>1068inline int INDEX_HASHTABLE<T> :: GetNBags () const1069{1070return hash.Size();1071}10721073template<class T>1074inline int INDEX_HASHTABLE<T> :: GetBagSize (int bnr) const1075{1076return hash.EntrySize(bnr);1077}10781079template<class T>1080inline void INDEX_HASHTABLE<T> :: GetData (int bnr, int colnr, INDEX & ahash, T & acont) const1081{1082ahash = hash.Get(bnr, colnr);1083acont = cont.Get(bnr, colnr);1084}10851086template<class T>1087inline void INDEX_HASHTABLE<T> :: PrintMemInfo (ostream & ost) const1088{1089ost << "Hash: " << endl;1090hash.PrintMemInfo (ost);1091ost << "Cont: " << endl;1092cont.PrintMemInfo (ost);1093}1094109510961097109810991100110111021103110411051106110711081109/* *********** Closed Hashing ************************* */1110111111121113template<class T>1114inline INDEX_2_CLOSED_HASHTABLE<T> ::1115INDEX_2_CLOSED_HASHTABLE (int size)1116: BASE_INDEX_2_CLOSED_HASHTABLE(size), cont(size)1117{1118cont.SetName ("i2-hashtable, contents");1119}11201121template<class T>1122inline void INDEX_2_CLOSED_HASHTABLE<T> ::1123Set (const INDEX_2 & ahash, const T & acont)1124{1125int pos;1126PositionCreate (ahash, pos);1127hash.Elem(pos) = ahash;1128cont.Elem(pos) = acont;1129}11301131template<class T>1132inline const T & INDEX_2_CLOSED_HASHTABLE<T> ::1133Get (const INDEX_2 & ahash) const1134{1135int pos = Position (ahash);1136return cont.Get(pos);1137}11381139template<class T>1140inline bool INDEX_2_CLOSED_HASHTABLE<T> ::1141Used (const INDEX_2 & ahash) const1142{1143int pos = Position (ahash);1144return (pos != 0);1145}11461147template<class T>1148inline void INDEX_2_CLOSED_HASHTABLE<T> ::1149SetData (int pos, const INDEX_2 & ahash, const T & acont)1150{1151hash.Elem(pos) = ahash;1152cont.Elem(pos) = acont;1153}11541155template<class T>1156inline void INDEX_2_CLOSED_HASHTABLE<T> ::1157GetData (int pos, INDEX_2 & ahash, T & acont) const1158{1159ahash = hash.Get(pos);1160acont = cont.Get(pos);1161}11621163template<class T>1164inline void INDEX_2_CLOSED_HASHTABLE<T> ::1165SetData (int pos, const T & acont)1166{1167cont.Elem(pos) = acont;1168}11691170template<class T>1171inline void INDEX_2_CLOSED_HASHTABLE<T> ::1172GetData (int pos, T & acont) const1173{1174acont = cont.Get(pos);1175}117611771178template<class T>1179inline void INDEX_2_CLOSED_HASHTABLE<T> ::1180SetSize (int size)1181{1182BaseSetSize(size);1183cont.SetSize(size);1184}1185118611871188template<class T>1189inline void INDEX_2_CLOSED_HASHTABLE<T> ::1190PrintMemInfo (ostream & ost) const1191{1192cout << "Hashtable: " << Size()1193<< " entries of size " << sizeof(INDEX_2) << " + " << sizeof(T)1194<< " = " << Size() * (sizeof(INDEX_2) + sizeof(T)) << " bytes."1195<< " Used els: " << UsedElements()1196<< endl;1197}11981199120012011202120312041205120612071208120912101211121212131214/*1215template<class T>1216inline INDEX_3_CLOSED_HASHTABLE<T> ::1217INDEX_3_CLOSED_HASHTABLE (int size)1218: BASE_INDEX_3_CLOSED_HASHTABLE(size), cont(size)1219{1220cont.SetName ("i3-hashtable, contents");1221}12221223template<class T>1224inline void INDEX_3_CLOSED_HASHTABLE<T> ::1225Set (const INDEX_3 & ahash, const T & acont)1226{1227int pos;1228PositionCreate (ahash, pos);1229hash.Elem(pos) = ahash;1230cont.Elem(pos) = acont;1231}12321233template<class T>1234inline const T & INDEX_3_CLOSED_HASHTABLE<T> ::1235Get (const INDEX_3 & ahash) const1236{1237int pos = Position (ahash);1238return cont[pos];1239}12401241template<class T>1242inline bool INDEX_3_CLOSED_HASHTABLE<T> ::1243Used (const INDEX_3 & ahash) const1244{1245int pos = Position (ahash);1246return (pos != 0);1247}12481249template<class T>1250inline void INDEX_3_CLOSED_HASHTABLE<T> ::1251SetData (int pos, const INDEX_3 & ahash, const T & acont)1252{1253hash.Elem(pos) = ahash;1254cont.Elem(pos) = acont;1255}12561257template<class T>1258inline void INDEX_3_CLOSED_HASHTABLE<T> ::1259GetData (int pos, INDEX_3 & ahash, T & acont) const1260{1261ahash = hash.Get(pos);1262acont = cont.Get(pos);1263}12641265template<class T>1266inline void INDEX_3_CLOSED_HASHTABLE<T> ::1267SetData (int pos, const T & acont)1268{1269cont.Elem(pos) = acont;1270}12711272template<class T>1273inline void INDEX_3_CLOSED_HASHTABLE<T> ::1274GetData (int pos, T & acont) const1275{1276acont = cont.Get(pos);1277}12781279template<class T>1280inline const T & INDEX_3_CLOSED_HASHTABLE<T> ::1281GetData (int pos) const1282{1283return cont.Get(pos);1284}128512861287template<class T>1288inline void INDEX_3_CLOSED_HASHTABLE<T> ::1289SetSize (int size)1290{1291BaseSetSize(size);1292cont.SetSize(size);1293}12941295template<class T>1296inline void INDEX_3_CLOSED_HASHTABLE<T> ::1297PrintMemInfo (ostream & ost) const1298{1299cout << "Hashtable: " << Size()1300<< " entries of size " << sizeof(INDEX_3) << " + " << sizeof(T)1301<< " = " << Size() * (sizeof(INDEX_3) + sizeof(T)) << " bytes" << endl;1302}1303*/130413051306130713081309131013111312131313141315131613171318131913201321#endif132213231324