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

📄 ugraph.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/dstr/UGraph/UGraph.h// version: $Id: UGraph.h,v 1.1 2001/01/17 17:46:59 alphonso Exp $//// make sure definitions are only made once//#ifndef ISIP_U_GRAPH#define ISIP_U_GRAPH// isip include files//#ifndef ISIP_DI_GRAPH#include <DiGraph.h>#endif#ifndef ISIP_DOUBLE_LINKED_LIST#include <DoubleLinkedList.h>#endif#ifndef ISIP_BOOLEAN#include <Boolean.h>#endif#ifndef ISIP_COLOR_HASH#include <ColorHash.h>#endif#ifndef ISIP_GRAPH_VERTEX#include <GraphVertex.h>#endif// forward class definitions://  we must define the GraphVertex class here first because the header files//  might be short-circuited by the ifndef.//template<class TObject> class ColorHash;template<class TObject> class GraphVertex;// UGraph: a generic two-way directed-graph template class. it is// implemented with something close to an adjacency list, with data// held on the vertices. each vertex holds both a TObject* and a list// of all emanating arcs. a graph can be in either USER or SYSTEM// allocated mode, for a USER-allocated list the TObject data is never// copied.//template<class TObject>class UGraph : public DiGraph<TObject> {  //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:    // define the class name  //  static const String CLASS_NAME;    //----------------------------------------  //  // i/o related constants  //  //----------------------------------------      //----------------------------------------  //  // dummy objects for start and end vertices  //  //----------------------------------------    //----------------------------------------  //  // default values and arguments  //  //----------------------------------------  // default values  //  // default arguments to methods  //    //----------------------------------------  //  // error codes  //  //----------------------------------------      //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:  //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // static methods  //  diagnose method is moved outside the class header file and  //  defined in the DiGraphDiagnose.h in order to avoid issues  //  related to preprocessing of the diagnose code.  //  static const String& name();  // destructor  //  ~UGraph() {}  // default constructor  //  UGraph(ALLOCATION alloc = DEF_ALLOCATION) : DiGraph<TObject> (alloc) {}  // copy constructor  //  UGraph(const UGraph<TObject>& copy_graph) : DiGraph<TObject> (copy_graph) {}  // assign methods:  //  having the same vertex appear in two different graphs is not allowed.  //  thus, memory is created for copied vertices even if the graph is in  //  user-allocating mode!  //  boolean assign(const UGraph<TObject>& copy_graph);  // method: operator=  //  UGraph<TObject>& operator=(const UGraph<TObject>& arg) {    assign(arg);    return *this;  }  // equality method  //  boolean eq(const UGraph<TObject>& compare_graph) const;    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  graph manipulation methods  //  //---------------------------------------------------------------------------  // method: insertArc  //  boolean insertArc(long start_index, long end_index,		    boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON,		    float weight = GraphArc<TObject>::DEF_WEIGHT) {    return insertArc(getPosition(start_index), getPosition(end_vertex),		     is_epsilon, weight);  }  // other arc insertion methods  //  boolean insertArc(GraphVertex<TObject>* start_vertex,		    GraphVertex<TObject>* end_vertex,		    boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON,		    float weight = GraphArc<TObject>::DEF_WEIGHT);    // method: removeArc  //  boolean removeArc(long start_index, long end_index) {    return removeArc(getPosition(start_index), getPosition(end_vertex));  }  // other arc removal methods  //    boolean removeArc(GraphVertex<TObject>* start_vertex,		    GraphVertex<TObject>* end_vertex);  //---------------------------------------------------------------------------  //  // private methods  //  //---------------------------------------------------------------------------private:};//-----------------------------------------------------------------------------//// 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 UGraph<TObject>::CLASS_NAME(L"UGraph");// below are all the methods for the UGraph 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& UGraph<TObject>::name() {  // create the static name string for this class and return it  //  static String cname(CLASS_NAME);  cname.clear(Integral::RESET);  cname.concat(CLASS_NAME);  cname.concat(L"<");  cname.concat(TObject::name());  cname.concat(L">");  // return the name  //  return cname;}//-------------------------------------------------------------------------////  required assign methods////-------------------------------------------------------------------------// method: assign//// arguments://  UGraph<TObject>& copy_graph: (input) the graph to copy//// return: a boolean value indicating status//// this is the assign method for the UGraph class. we can't just copy// the data over since the arcs make connections by pointer (and we// can't share vertices across two graphs), hence we must manually// insert every vertex and every arc. new vertices are created, but if// the graph is in USER mode the tobject is not copied.//template<class TObject>boolean UGraph<TObject>::assign(const UGraph<TObject>& arg_a) {  // copy the weighting flag.  //  is_weighted_d = arg_a.is_weighted_d;  // copy the allocation flag  //  alloc_d = arg_a.alloc_d;    // save the state of the input graph  //  long old_pos = const_cast<UGraph<TObject>& >(arg_a).getPosition();    // we need to build a cross-referencing scheme to make sure we cover  // all arcs and all nodes. the (+2) is for the start and terminal  // vertices since they are NOT included in the list  //  long num_vertices = arg_a.length() + 2;    GraphVertex<TObject>* copy_sym_ptrs[num_vertices];  GraphVertex<TObject>* this_sym_ptrs[num_vertices];  // set the start and terminal vertices  //  copy_sym_ptrs[0] = arg_a.getStart();  copy_sym_ptrs[num_vertices - 1] = arg_a.getTerm();    // loop through the list of vertices, and number them  //  const_cast<UGraph<TObject>& >(arg_a).gotoFirst();  for (long i = 1; i < num_vertices - 1; i++) {    // get the current node in the graph and assign it to the array    //

⌨️ 快捷键说明

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