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

📄 treenode.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/dstr/TreeNode/TreeNode.h// version: $Id: TreeNode.h,v 1.1 2002/08/23 01:06:42 alphonso Exp $//// make sure definitions are made only once//#ifndef ISIP_TREE_NODE#define ISIP_TREE_NODE// isip include files//#ifndef ISIP_LONG#include <Long.h>#endif#ifndef ISIP_NODE#include <Node.h>#endif#ifndef ISIP_CONSOLE#include <Console.h>#endif// forward class definitions//template<class TObject> class TreeNodeDiagnose;// TreeNode: this class implements a TreeNode data structure that forms the// basis of the Tree class//template<class TObject>class TreeNode : public Node<TObject> {      //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:    // define the class name  //  static const String CLASS_NAME;  //----------------------------------------  //  // i/o related constants  //  //----------------------------------------      static const String DEF_PARAM;    //----------------------------------------  //  // default values and arguments  //  //----------------------------------------    // default values  //  static const long DEF_DEGREE = 0;    // default arguments to methods  //    //----------------------------------------  //  // error codes  //  //----------------------------------------      //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:  // define a pointer to the parent node  //  TreeNode<TObject>* parent_d;    // define a pointer to the left child node  //  TreeNode<TObject>* left_d;  // define a pointer to the right child node  //  TreeNode<TObject>* right_d;        // define the out degree of the node  //  Long degree_d;    // debugging parameters  //  static Integral::DEBUG debug_level_d;  // define the memory manager  //    static MemoryManager mgr_d;    //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:    // static methods:  //  the diagnose method is moved outside the class header file and  //  defined in the TreeNodeDiagnose.h in order to avoid issues  //  with preprocessing of the diagnose code.  //  static const String& name();    // method: setDebug  //  static boolean setDebug(Integral::DEBUG debug_level) {    debug_level_d = debug_level;    return true;  }  // other debug methods  //  boolean debug(const unichar* msg) const;       // destructor/constructor(s)  //  ~TreeNode();  TreeNode(TObject* item = (TObject*)NULL);  TreeNode(const TreeNode<TObject>& copy_tnode);  // assign method  //  boolean assign(const TreeNode<TObject>& copy_stack);    // method: operator=  //  TreeNode<TObject>& operator=(const TreeNode<TObject>& arg) {    assign(arg);    return *this;  }  // equality method  //  boolean eq(const TreeNode<TObject>& arg) const;    // method: read  //  boolean read(Sof& sof, long tag) {    return read(sof, tag, name());  }  // method: write  //  boolean write(Sof& sof, long tag) const {    return write(sof, tag, name());  }  // method: sofSize  //  long sofSize() const {    return 0;  }  // method: read  //  boolean read(Sof& sof, long tag, const String& name) {    return Error::handle(name(), L"read", Error::ARG, __FILE__, __LINE__);  }  // method: write  //  boolean write(Sof& sof, long tag, const String& name) const {    return Error::handle(name(), L"write", Error::ARG, __FILE__, __LINE__);  }  // method: readData  //  boolean readData(Sof& sof, const String& pname = DEF_PARAM,		   long size = SofParser::FULL_OBJECT,                   boolean param = true,		   boolean nested = true) {    return Error::handle(name(), L"readData", Error::ARG, __FILE__, __LINE__);  }  // method: writeData  //  boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const {    return Error::handle(name(), L"writeData", Error::ARG, __FILE__, __LINE__);  }  // method: new  //  static void* operator new(size_t size) {    return mgr_d.get();  }  // method: new[]  //  static void* operator new[](size_t size) {    return mgr_d.getBlock(size);  }  // method: delete  //  static void operator delete(void* ptr) {    mgr_d.release(ptr);  }  // method: delete[]  //  static void operator delete[](void* ptr) {    mgr_d.releaseBlock(ptr);  }  // method: setGrowSize  //  static boolean setGrowSize(long grow_size) {    return mgr_d.setGrow(grow_size);  }      // clear method  //  boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  tree node manipulation methods  //  //---------------------------------------------------------------------------  // method: degree  //  long degree() const {    return (long)degree_d;  }    // method: increment  //  boolean increment() {    degree_d = (long)degree_d + 1;    return true;  }  // method: decrement  //  boolean decrement() {    degree_d = (long)degree_d - 1;    return true;  }      // method: getParent  //  TreeNode<TObject>* getParent() const {    return parent_d;  }    // method: setParent  //  boolean setParent(const TreeNode<TObject>* arg) {    parent_d = const_cast<TreeNode<TObject>* >(arg);    return true;  }  // method: getLeftChild  //  TreeNode<TObject>* getLeftChild() const {    return left_d;  }  // method to set the left child of the node  //  boolean setLeftChild(const TreeNode<TObject>* arg);  // method: getRightSibling  //  TreeNode<TObject>* getRightSibling() const {    return right_d;  }  // method to set the right sibling of the node  //  boolean setRightSibling(const TreeNode<TObject>* arg);  // node adjacency methods  //  boolean isAdjacent(const TObject* obj) const;      boolean isAdjacent(const TreeNode<TObject>* node) const;    //---------------------------------------------------------------------------  //  // private methods  //  //---------------------------------------------------------------------------private:  // declare friend classes  //  template <class TObject_diagnose>   friend class TreeNodeDiagnose;  };//-----------------------------------------------------------------------------//// 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 TreeNode<TObject>::CLASS_NAME(L"TreeNode");template <class TObject>const String TreeNode<TObject>::DEF_PARAM(L"values");// static instantiations: debug level//template <class TObject>Integral::DEBUG TreeNode<TObject>::debug_level_d = Integral::NONE;// static instantiations: the memory manager//template <class TObject>MemoryManager TreeNode<TObject>::mgr_d(sizeof(TreeNode<TObject>), CLASS_NAME);// below are all the methods for the TreeNode 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& TreeNode<TObject>::name() {    // create the static name string for this class and return it  //  static String cname(CLASS_NAME);  cname.clear();  cname.concat(CLASS_NAME);

⌨️ 快捷键说明

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