⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bicolorhash.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
字号:
// file: $isip/class/dstr/BiColorHash/BiColorHash.h// version: $Id: BiColorHash.h,v 1.2 2001/06/20 20:07:18 alphonso Exp $//// make sure definitions are only made once://#ifndef ISIP_BI_COLOR_HASH#define ISIP_BI_COLOR_HASH// forward class definitions for the inner classes//class BiGVColor;template<class TVertex> class BiGVKey;// isip include files//#ifndef ISIP_HASH_TABLE#include <HashTable.h>#endif#ifndef ISIP_NAME_MAP#include <NameMap.h>#endif#ifndef ISIP_BIGRAPH_VERTEX#include <BiGraphVertex.h>#endif// BiColorHash: the main function of this class is to create a one-to-one mapping// between a graph vertex pointer and the corresponding color of the vertex.// we use a separate class for this so that it is possible to have a// graph vertex without the notion of color, which would waste memory// for applications not needing color.//template<class TObject>class BiColorHash : public DstrBase {    //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:  // define the class name. also include names for the inner classes.  //  static const String CLASS_NAME;  static const String GV_KEY_CLASS_NAME;  static const String GV_COLOR_CLASS_NAME;  //----------------------------------------  //  // other important constants  //  //----------------------------------------    //----------------------------------------  //  // default values and arguments  //  //----------------------------------------  // default values  //    // default arguments to methods  //  //----------------------------------------  //  // error codes  //  //----------------------------------------  //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:  // define a typedef for the BiColorHash template  //  typedef BiColorHash<TObject> CHASH;  // define the internal hash table instance  //  HashTable<BiGVKey<TObject>, BiGVColor> hash_d;    // debugging parameters  //  static Integral::DEBUG debug_level_d;    //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // static methods:  //  static const String& name();    // method: setDebug  //  static boolean setDebug(Integral::DEBUG arg) {    debug_level_d = arg;    return true;  }  // other debug methods  //  boolean debug(const unichar* message) const;  // method: destructor  //  ~BiColorHash() {}    // method: default constructor  //  BiColorHash() {}    // method: copy constructor  //  BiColorHash(const CHASH& arg) {    assign(arg);  }  // method: assign  //  boolean assign(const CHASH& arg) {    return hash_d.assign(arg.hash_d);  }    // method: operator=  //  CHASH operator=(const CHASH& arg) {    assign(arg);    return *this;  }  // method: eq  //  boolean eq(const CHASH& arg) const {    return hash_d.eq(arg.hash_d);  }    // i/o methods:  //  these methods are not defined for this class  //    // memory-management methods:  //  these methods are not defined for this class  //  // method: clear  //  boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE) {    return hash_d.clear(cmode);  }    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  hash table property methods  //  //---------------------------------------------------------------------------    // method: getNumItems  //  long getNumItems() const {    return hash_d.getNumItems();  }  // method: isEmpty  //  boolean isEmpty() const {    return hash_d.isEmpty();  }    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  hash table get and set methods  //  //---------------------------------------------------------------------------    // method: get  //  Integral::COLOR get(const BiGraphVertex<TObject>* key) {    const BiGVKey<TObject> arg1(key);    BiGVColor* col = hash_d.get(arg1);    if (col == (BiGVColor*)NULL) {      Error::handle(name(), L"get", ERR, __FILE__, __LINE__);      return (Integral::COLOR)NULL;    }    return col->get();  }  // method: get  //  const Integral::COLOR get(const BiGraphVertex<TObject>* key) const {    const BiGVKey<TObject> arg1(key);    BiGVColor* col = hash_d.get(arg1);    if (col == (BiGVColor*)NULL) {      Error::handle(name(), L"get", ERR, __FILE__, __LINE__);      return (Integral::COLOR)NULL;    }    return col->get();  }  // method: set  //  boolean set(const BiGraphVertex<TObject>* key, Integral::COLOR value) {    const BiGVKey<TObject> arg1(key);    BiGVColor* col = hash_d.get(arg1);    if (col == (BiGVColor*)NULL) {      Error::handle(name(), L"set", ERR, __FILE__, __LINE__);      return (Integral::COLOR)NULL;    }    return col->assign(value);  }  //---------------------------------------------------------------------------  //  // class-specific public methods:  //  hash table insert and remove methods  //  //---------------------------------------------------------------------------    // method: insert  //  boolean insert(const BiGraphVertex<TObject>* key, Integral::COLOR value) {    const BiGVKey<TObject> arg1(key);    BiGVColor arg2(value);    return hash_d.insert(arg1, &arg2);  }  // method: remove  //  boolean remove(const BiGraphVertex<TObject>* key) {    BiGVKey<TObject> arg1(key);    if (!hash_d.remove(arg1)) {      return Error::handle(name(), L"remove", ERR, __FILE__, __LINE__);    }    return true;  }  //---------------------------------------------------------------------------  //  // class-specific public methods:  //  hash table contains methods  //  //---------------------------------------------------------------------------    // method: containsKey  //  boolean containsKey(const BiGraphVertex<TObject>* key) const {    const BiGVKey<TObject> arg1(key);    return hash_d.containsKey(arg1);  }  // method: containsValue  //  boolean containsValue(const Integral::COLOR value) const {    BiGVColor arg1(value);    return hash_d.containsValue(&arg1);  }    //---------------------------------------------------------------------------  //  // private methods  //  //---------------------------------------------------------------------------private:};  //---------------------------------------------------------------------------  //  // inner classes  //  //---------------------------------------------------------------------------// BiGVColor: the main function of this class is to act a wrapper for the// graph vertex class. this class stores the color values of the graph// vertices that tell us if the vertex has been previously visited.//class BiGVColor {    //-------------------------------------------------------------------------    //    // protected data    //    //-------------------------------------------------------------------------  protected:        // BiGVColor value    //    Integral::COLOR color_d;        //-------------------------------------------------------------------------    //    // public methods    //    //-------------------------------------------------------------------------  public:        // method: name    //    static const String& name() {      return BiColorHash<Char>::GV_COLOR_CLASS_NAME;    }        // method: debug    //     boolean debug(const unichar* message_a) const {            // build a debug string      //      String output;      output.debugStr(name(), message_a, L"color",		      NameMap::COLOR_MAP((long)color_d));      Console::put(output);            // exit gracefully      //       return true;    }    // method: destructor    //    ~BiGVColor() {}        // method: default constructor    //    BiGVColor(Integral::COLOR arg = Integral::DEF_COLOR) {      color_d = arg;    }        // method: copy constructor    //    BiGVColor(BiGVColor& arg) {      assign(arg);    }    // method: assign    //    boolean assign(const BiGVColor& arg) {      color_d = arg.color_d;      return true;    }        // method: eq    //    boolean eq(const BiGVColor& arg) const {      return (color_d == arg.color_d);    }        // method: clear    //    boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE) {      return (color_d = Integral::DEF_COLOR);    }        // method: assign    //    boolean assign(const Integral::COLOR arg) {      color_d = arg;      return true;    }          // method: get    //    Integral::COLOR get() {      return color_d;    }  };// BiGVKey: the main function of this class is to make pointers to the graph// vertex class hashable. this class contains a pointer to a graph vertex// and determines the hash index that corresponds to the hash index.//template<class TVertex>class BiGVKey : public Node<BiGraphVertex<TVertex > > {    //-------------------------------------------------------------------------  //  // public methods  //  //-------------------------------------------------------------------------public:    // method: name  //  static const String& name() {        // create the static name string for this class and return it    //    static String cname(BiColorHash<TVertex>::GV_KEY_CLASS_NAME);    cname.clear();    cname.concat(BiColorHash<TVertex>::CLASS_NAME);    cname.concat(L"<");    cname.concat(TVertex::name());    cname.concat(L">");        // return the name    //    return cname;  }    // method: debug  //  boolean debug(const unichar* message_a) const {        // build a debug string    //    String output;    String value;    value.assign(item_d);    output.debugStr(name(), message_a, L"item", value);    Console::put(output);        // exit gracefully    //     return true;  }    // method: destructor  //  ~BiGVKey() {}    // method: default constructor  //  BiGVKey() {}    // method: copy constructor  //  BiGVKey(BiGVKey<TVertex>& arg) {    item_d = arg.item_d;  }    // method: copy constructor  //  BiGVKey(const BiGraphVertex<TVertex>* arg) {    item_d = const_cast<BiGraphVertex<TVertex>*>(arg);  }    // method: assign  //  boolean assign(const BiGVKey<TVertex>& arg) {    item_d = arg.item_d;    return true;  }    // method: eq  //  boolean eq(const BiGVKey<TVertex>& arg) const {    return (item_d == arg.item_d);  }};//-----------------------------------------------------------------------------//// we define non-integral constants at the end of class definition for// templates (for non-templates these are defined in the default constructor)//      //-----------------------------------------------------------------------------// constants: required constants such as the class name//template <class TObject>const String BiColorHash<TObject>::CLASS_NAME(L"BiColorHash");template <class TObject>const String BiColorHash<TObject>::GV_KEY_CLASS_NAME(L"BiGVKey");template <class TObject>const String BiColorHash<TObject>::GV_COLOR_CLASS_NAME(L"BiGVColor");// static instantiations: debug level//template <class TObject>Integral::DEBUG BiColorHash<TObject>::debug_level_d = Integral::NONE;// below are all the methods for the BiColorHash template class////-----------------------------------------------------------------------------//// required static methods////-----------------------------------------------------------------------------// method: name//// arguments: none//// return: a static String& containing the class name//// this method returns the class name//template <class TObject>const String& BiColorHash<TObject>::name() {  // create the static name string for this class and return it  //  static String cname(CLASS_NAME);  cname.clear();  cname.concat(CLASS_NAME);  cname.concat(L"<");  cname.concat(TObject::name());  cname.concat(L">");  // return the name  //  return cname;}// method: debug//// arguments://  const unichar* message: (input) information message//// return: a boolean value indicating status//// this method dumps the contents of an object to the console// template<class TObject>boolean BiColorHash<TObject>::debug(const unichar* message_a) const {  // build a debug string  //  String val;  String output;  output.debugStr(name(), message_a, L"hash_d");  Console::put(output);    Console::increaseIndention();  // dump the this pointer  //  hash_d.debug(L"");    // that's it for sub-items, decrease indentation  //  Console::decreaseIndention();  // exit gracefully  //   return true;}// end of include file// #endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -