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

📄 doublelinkedlistdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 4 页
字号:
// file: $isip/class/dstr/DoubleLinkedList/DoubleLinkedListDiagnose.h// version: $Id: DoubleLinkedListDiagnose.h,v 1.12 2001/11/12 20:11:23 gao Exp $//// make sure definitions are made only once//#ifndef ISIP_DOUBLE_LINKED_LIST_DIAGNOSE#define ISIP_DOUBLE_LINKED_LIST_DIAGNOSE// isip include files//#ifndef ISIP_DOUBLE_LINKED_LIST#include "DoubleLinkedList.h"#endif// DoubleLinkedListDiagnose: a class that contains the diagnose method// of DoubleLinkedList class.//template<class TObject>class DoubleLinkedListDiagnose : public DoubleLinkedList<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:    // method: name  //  static const String& name() {    return DoubleLinkedList<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 DoubleLinkedListDiagnose 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 DoubleLinkedListDiagnose<TObject>::diagnose(Integral::DEBUG level_a) {  //----------------------------------------------------------------------  //  // 0. preliminaries  //  //----------------------------------------------------------------------  // output the class name  //  if (level_a > Integral::NONE) {    SysString output(L"diagnosing class ");    output.concat(CLASS_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 debug methods  //  setDebug(debug_level_d);    if (level_a > Integral::BRIEF) {    Integral::debug(L"debug");  }  // prepare items for all the lists used in this diagnose   //  long num_elem = 10;  Char** items = new Char*[num_elem];    for (long i = 0; i < num_elem; i++) {    items[i] = new Char((unichar)((long)'a' + i));  }    // test constructors and memory management  //  DoubleLinkedList<Char> def_list;  def_list.insertFirst(items[0]);  def_list.insert(items[1]);  def_list.insertLast(items[2]);  // copy constructor  //  DoubleLinkedList<Char> copy_list(def_list);         // the two constructed lists should have the same items in the nodes now  //  if (def_list.ne(copy_list)) {    return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__,			 __LINE__);  }  // print out the list  //  if (level_a >= Integral::ALL) {    def_list.debug(L"def_list");  }    // check the constructors and destructors for allocating on the dynamic  // memory heap  //  DoubleLinkedList<Char>* def_dyn_list = new DoubleLinkedList<Char>();  def_dyn_list->insertFirst(items[0]);  def_dyn_list->insert(items[1]);  def_dyn_list->insertLast(items[2]);    DoubleLinkedList<Char>* copy_dyn_list =    new DoubleLinkedList<Char>(*def_dyn_list);    // the two constructed lists should have the same items in their nodes now  //  if (def_dyn_list->ne(copy_list)) {    return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__,			 __LINE__);  }    // see if we can dynamically delete  //  delete def_dyn_list;  delete copy_dyn_list;    // when memory is USER-allocated  //    // check the constructors for allocating on the stack  //  DoubleLinkedList<Char> def_list_2;  def_list_2.setAllocationMode(USER);  def_list_2.insertFirst(items[0]);  def_list_2.insert(items[1]);  def_list_2.insertLast(items[2]);    DoubleLinkedList<Char> copy_list_2(def_list_2);    // the two constructed lists should have the same items in the nodes now  //  if (def_list_2.ne(copy_list_2)) {    return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__,			 __LINE__);  }  if (def_list_2.getAllocationMode() != copy_list_2.getAllocationMode()) {    return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__, __LINE__);  }    // check the constructors and destructors for allocating on the dynamic  // memory heap  //  DoubleLinkedList<Char>* def_dyn_list_2 =    new DoubleLinkedList<Char>(USER);    def_dyn_list_2->insertFirst(items[0]);  def_dyn_list_2->insert(items[1]);  def_dyn_list_2->insertLast(items[2]);    DoubleLinkedList<Char>* copy_dyn_list_2 =    new DoubleLinkedList<Char>(*def_dyn_list_2);    // the two constructed lists should have the same items in their nodes now  //  if (def_dyn_list_2->ne(copy_list_2)) {    return Error::handle(name(), L"copy constructor", Error::TEST, __FILE__,			 __LINE__);  }    // see if we can dynamically delete  //  delete def_dyn_list_2;  delete copy_dyn_list_2;    // test large allocation construction and deletion  //  if (level_a >= Integral::ALL) {        // output an informative message    //    Console::put(L"\ntesting large chunk memory allocation and deletion:\n");        // set the memory to a strange block size so we can hopefully catch any    // frame overrun errors    //    DoubleLinkedList<Char>::setGrowSize((long)731);        // loop for a large number of times creating and deleting a large number    // of lists at each loop    //    for (long j = 1; j <= 10; j++) {      DoubleLinkedList<Char>** system_lists =	new DoubleLinkedList<Char>*[j * 100];      DoubleLinkedList<Char>** lists =	new DoubleLinkedList<Char>*[j * 100];            // create the items      //      for (long i = 0; i < j * 100; i++) {	system_lists[i] =  new DoubleLinkedList<Char>(USER);	lists[i] =  new DoubleLinkedList<Char>();      }            // delete lists      //      for (long i = (j * 100) - 1; i >= 0; i--) {	delete system_lists[i];	delete lists[i];      }            // clean up memory      //      delete [] system_lists;      delete [] lists;    }    // perform the same test using the new[] and delete [] operators    //    for (long j = 1; j <= 10; j++) {            // allocate a large number of nodes      //      DoubleLinkedList<TObject>* system_lists =	new DoubleLinkedList<TObject>[j * 100];      DoubleLinkedList<TObject>* lists =	new DoubleLinkedList<TObject>[j * 100](USER);      // clean up memory      //      delete [] system_lists;      delete [] lists;    }  }    // test assign methods  //    DoubleLinkedList<Char> tmp_list;           DoubleLinkedList<Char>* tmp_dyn_list = new DoubleLinkedList<Char>();  DoubleLinkedList<Char> tmp_list_1(USER);   DoubleLinkedList<Char>* tmp_dyn_list_1 = new DoubleLinkedList<Char>(USER);  Char* item_ptr = (Char*)NULL;  // insert an item into the list  //  tmp_list.insert(items[0]);  tmp_list_1.insert(items[0]);    // try the list assign method  //  tmp_dyn_list->assign(tmp_list);  tmp_dyn_list_1->assign(tmp_list_1);    if (tmp_dyn_list->ne(tmp_list) || tmp_dyn_list->ne(tmp_list_1)) {    return Error::handle(name(), L"list assign", Error::TEST, __FILE__,			 __LINE__);  }    if (tmp_dyn_list_1->ne(tmp_list) || tmp_dyn_list_1->ne(tmp_list_1)) {    return Error::handle(name(), L"list assign", Error::TEST, __FILE__,			 __LINE__);  }    // clean up  //  delete tmp_dyn_list;  delete tmp_dyn_list_1;    // testing i/o methods  //  String text_filename;  Integral::makeTemp(text_filename);  String bin_filename;  Integral::makeTemp(bin_filename);    // open files in write mode  //  Sof text_file;  text_file.open(text_filename, File::WRITE_ONLY, File::TEXT);  Sof bin_file;  bin_file.open(bin_filename, File::WRITE_ONLY, File::BINARY);    // prepare items for the lists  //  Char** write_chars = new Char*[5];  String** write_strings = new String*[5];    unichar tmp_char = L'a';    for (long j = 0; j < 5; j++) {    write_chars[j] = new Char(tmp_char);    write_strings[j] = new String();    tmp_char++;  }    write_strings[0]->assign(L"this ");  write_strings[1]->assign(L"is");  write_strings[2]->assign(L"a");  write_strings[3]->assign(L"DoubleLinkedList");  write_strings[4]->assign(L"String");    // create lists to write  //  DoubleLinkedList<Char> write_null_list;  DoubleLinkedList<Char> write_char_list(USER);  write_char_list.insert(write_chars[0]);    DoubleLinkedList<String> write_str_list(USER);  for (long i = 0; i < 5; i++) {    write_str_list.insert(write_strings[i]);  }    DoubleLinkedList< DoubleLinkedList<Char> >    write_char_list_list(USER);  DoubleLinkedList< DoubleLinkedList< DoubleLinkedList<Char> > >    write_char_lll(USER);    // create objects for reading in, all read lists are SYSTEM-allocated  //  DoubleLinkedList<Char> read_null_list_text;  DoubleLinkedList<Char> read_null_list_bin;  DoubleLinkedList<Char> read_char_list_text;  DoubleLinkedList<Char> read_char_list_bin;  DoubleLinkedList<String> read_str_list_text;  DoubleLinkedList<String> read_str_list_bin;    DoubleLinkedList< DoubleLinkedList<Char> > read_char_list_list_bin;  DoubleLinkedList< DoubleLinkedList<Char> > read_char_list_list_text;    DoubleLinkedList< DoubleLinkedList< DoubleLinkedList<Char> > >    read_char_lll_bin, read_char_lll_text;    long s1 = 3;  long s2 = 5;    // create items for writing  //  DoubleLinkedList< DoubleLinkedList<Char> >* wc_ll_0 =    new DoubleLinkedList< DoubleLinkedList<Char> >(USER);  DoubleLinkedList< DoubleLinkedList<Char> >* wc_ll_1 =    new DoubleLinkedList< DoubleLinkedList<Char> >(USER);    // write_char_list_list is in USER mode, each sub-list  // is in USER mode.  //  for (long i = 0; i < s1; i++) {        DoubleLinkedList<Char>* temp = new DoubleLinkedList<Char>(USER);    DoubleLinkedList<Char>* t1 = new DoubleLinkedList<Char>(USER);    DoubleLinkedList<Char>* t2 = new DoubleLinkedList<Char>(USER);        for (long j = 0; j < s2; j++) {      Char* c1 = new Char();      Char* c2 = new Char();      Char* c3 = new Char();      c1->assign((unichar)(i * (s2+1) + j + (int)'A'));      c2->assign((unichar)(i * (s2+1) + j + (int)'A'));      c3->assign((unichar)(i * (s2+1) + j + (int)'a'));      temp->insert(c1);      t1->insert(c2);      t2->insert(c3);    }        write_char_list_list.insert(temp);    

⌨️ 快捷键说明

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