📄 bicolorhashdiagnose.h
字号:
// file: $isip/class/dstr/BiColorHash/BiColorHashDiagnose.h// version: $Id: BiColorHashDiagnose.h,v 1.1 2001/06/18 18:12:06 alphonso Exp $//// make sure definitions are only made once//#ifndef ISIP_GVHASH_DIAGNOSE#define ISIP_GVHASH_DIAGNOSE// isip include files//#ifndef ISIP_GVHASH#include "BiColorHash.h"#endif// BiColorHashDiagnose: a class that contains the diagnose method of BiColorHash class.//template<class TObject>class BiColorHashDiagnose : public BiColorHash<TObject> { //--------------------------------------------------------------------------- // // public constants // //---------------------------------------------------------------------------public: // define the class name // //---------------------------------------- // // i/o related constants // //---------------------------------------- //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // // default arguments to methods // //---------------------------------------- // // error codes // //---------------------------------------- //--------------------------------------------------------------------------- // // protected data // //---------------------------------------------------------------------------protected: //--------------------------------------------------------------------------- // // required public methods // //---------------------------------------------------------------------------public: // methods: name // static const String& name() { return BiColorHash<TObject>::name(); } // other static methods // static boolean diagnose(Integral::DEBUG debug_level); // debug methods // these methods are omitted since this class does not have data // members and operations // // destructor/constructor(s): // these methods are omitted since this class does not have data // members and operations // // assign methods: // these methods are omitted since this class does not have data // members and operations // // operator= methods: // these methods are omitted since this class does not have data // members and operations // // i/o methods: // these methods are omitted since this class does not have data // members and operations // // equality methods: // these methods are omitted since this class does not have data // members and operations // // memory-management methods: // these methods are omitted since this class does not have data // members and operations // //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // these methods are omitted since this class does not have data // members and operations // //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private:}; // below are all the methods for the BiColorHashDiagnose template class////-----------------------------------------------------------------------------//// required static methods////-----------------------------------------------------------------------------// method: diagnose//// arguments:// Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//template<class TObject>boolean BiColorHashDiagnose<TObject>::diagnose(Integral::DEBUG level_a) { //--------------------------------------------------------------------------- // // 0. preliminaries // //--------------------------------------------------------------------------- // output the class name // if (level_a > Integral::NONE) { SysString output(L"diagnosing class "); output.concat(name()); output.concat(L": "); Console::put(output); Console::increaseIndention(); } //-------------------------------------------------------------------------- // // 1. required public methods // //-------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing required public methods...\n"); Console::increaseIndention(); } // test the constructors // BiGraphVertex<Char> vert_00; BiColorHash<Char> hash_00; hash_00.insert(&vert_00, Integral::BLACK); BiColorHash<Char> hash_01(hash_00); if (hash_00.get(&vert_00) != Integral::BLACK) { return Error::handle(name(), L"constructor", Error::TEST, __FILE__, __LINE__); } if (hash_01.get(&vert_00) != Integral::BLACK) { return Error::handle(name(), L"constructor", Error::TEST, __FILE__, __LINE__); } if (hash_00.get(&vert_00) != hash_01.get(&vert_00)) { return Error::handle(name(), L"constructor", Error::TEST, __FILE__, __LINE__); } // test assign methods // BiColorHash<Char> hash_02; hash_02.assign(hash_00); if (hash_02.get(&vert_00) != Integral::BLACK) { return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__); } // test operator= and equality methods // BiColorHash<Char> hash_03; hash_03 = hash_02; if (level_a > Integral::BRIEF) { hash_03.debug(L"hash_03"); } if (!hash_03.eq(hash_00)) { return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //-------------------------------------------------------------------------- // // 2. hash table property methods // //-------------------------------------------------------------------------- // set indentation // if (level_a > Integral::NONE) { Console::put(L"testing hash table property methods...\n"); Console::increaseIndention(); } // create a hash table // BiColorHash<Char> hash_04; // test the isEmpty method // if (!hash_04.isEmpty()) { return Error::handle(name(), L"isEmpty", Error::TEST, __FILE__, __LINE__); } // create some data // BiGraphVertex<Char> vert_01; BiGraphVertex<Char> vert_02; // add some vertices to the hash table // hash_04.insert(&vert_01, Integral::GREEN); hash_04.insert(&vert_02, Integral::WHITE); // test the getNumItems method // if (hash_04.getNumItems() != (long)2) { return Error::handle(name(), L"getNumItems()", Error::TEST, __FILE__, __LINE__); } // test the isEmpty method // if (hash_04.isEmpty()) { return Error::handle(name(), L"isEmpty", Error::TEST, __FILE__, __LINE__); } // reset indentation // if (level_a > Integral::NONE) { Console::decreaseIndention(); } //-------------------------------------------------------------------------- // // 3. hash table get and set methods // //-------------------------------------------------------------------------- // set indentation //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -