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

📄 queuediagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 4 页
字号:
    if (pos_queue_2.peek()->ne(*items[18]) || pos_queue_2.length() != 8) {    return Error::handle(name(), L"add/remove/mark methods failed",			 Error::TEST, __FILE__, __LINE__);  }    if (pos_queue_3.peek()->ne(*items[15]) || pos_queue_3.length() != 1) {    return Error::handle(name(), L"add/remove/mark methods failed",			 Error::TEST, __FILE__, __LINE__);  }    if (pos_queue_4.peek()->ne(*items[9]) || pos_queue_4.length() != 9) {    return Error::handle(name(), L"add/remove/mark methods failed",			 Error::TEST, __FILE__, __LINE__);  }    {    // test add, remove, peek and marking methods for reference mode    //    Queue<Char> pos_queue_1(USER);    Queue<Char> pos_queue_2(USER);    Queue<Char> pos_queue_3(USER);    Queue<Char> pos_queue_4(USER);    Queue<Char> temp_clear_queue(USER);        // test the various "add" methods in self-allocation mode    //  populate the first queue with all of the letters from 'a' - 'n' in    //  reverse order, marking the 'i'    //    for (long i = 0; i < 9; i++) {      pos_queue_1.add(items[i]);    }    pos_queue_1.setMark();    for (long i = 9; i < 14; i++) {      pos_queue_1.add(items[i]);    }        // make sure that the top element is the 'a'    //    if (pos_queue_1.peek() != items[0]) {      return Error::handle(name(), L"add", Error::TEST, __FILE__,			   __LINE__);    }        // make sure that the mark is set    //    if (!pos_queue_1.markIsSet()) {      return Error::handle(name(), L"setMark/markIsSet", Error::TEST, __FILE__,			   __LINE__);    }        // populate the second queue with the entire alphabet    //    pos_queue_2.add(items, num_elem);        // populate the third queue with all alphabets as well, but copied from    // the second queue    //    pos_queue_3.add(pos_queue_2);        // make sure that the second and third queue are the same    //    if (!pos_queue_2.eq(pos_queue_3)) {      return Error::handle(name(), L"add", Error::TEST, __FILE__,			   __LINE__);    }        // remove the first queue to the mark - it should now have 'i' - 'n' on it    //    pos_queue_1.removeToMark(temp_clear_queue);        // make sure the top item is the marked item    //    if (!(pos_queue_1.markIsSet() && pos_queue_1.isMarkedElement())) {      return Error::handle(name(), L"isMarkedElement", Error::TEST, __FILE__,			   __LINE__);    }        // make sure the top item is the 'i'    //    if (pos_queue_1.peek() != items[8]) {      return Error::handle(name(), L"removeToMark", Error::TEST, __FILE__,			   __LINE__);    }        // make sure the clearMark method works    //    pos_queue_1.clearMark();    if (pos_queue_1.markIsSet() || pos_queue_1.isMarkedElement()) {      return Error::handle(name(), L"clearMark", Error::TEST, __FILE__,			   __LINE__);    }        // mark the item again, the 'n' is marked    //    pos_queue_1.setMark();        // the second queue currently holds 'a' - 'z'. remove until we reach the 'r'    // add the items removed onto the fourth queue    //    while ((pos_queue_2.peek())->ne(*items[18])) {      Char* tmp_char_ptr2;      tmp_char_ptr2 = pos_queue_2.remove();      pos_queue_4.add(tmp_char_ptr2);    }        // the second queue now holds 'r' - 'z' and the fourth queue now holds    // 'a' - 'q'. remove the fourth queue so that it holds 'j' - 'q'    //    pos_queue_4.remove(temp_clear_queue, 9);        // now the first queue holds 'i' - 'n', the second queue holds 's' - 'z',    // the third queue holds 'a' - 'z' and the fourth holds 'j' - 'q'.    //        // call removeAll to put all items from the third queue onto the temp queue    //    pos_queue_3.removeAll(temp_clear_queue);        // make sure the third queue is empty    //    if (!pos_queue_3.isEmpty()) {      return Error::handle(name(), L"removeAll", Error::TEST, __FILE__,			   __LINE__);    }        // now remove elements off of the temp queue until we reach the 'p'    //    while ((temp_clear_queue.peek())->ne(*items[15])) {      temp_clear_queue.remove();    }        // remove the 'p' from the temp queue and add to the third queue    //    temp_clear_queue.remove(pos_queue_3, 1);        // now the first queue should have an 'i' at the top, the second queue    // should have a 's' at the top, the third queue should have a 'p' at the    // top, and the fourth queue should have a 'j' at the top.     //    if (pos_queue_1.peek()->ne(*items[8]) || pos_queue_1.length() != 6) {      return Error::handle(name(), L"add/remove/mark methods failed",			   Error::TEST, __FILE__, __LINE__);    }        if (pos_queue_2.peek()->ne(*items[18]) || pos_queue_2.length() != 8) {      return Error::handle(name(), L"add/remove/mark methods failed",			   Error::TEST, __FILE__, __LINE__);    }        if (pos_queue_3.peek()->ne(*items[15]) || pos_queue_3.length() != 1) {      return Error::handle(name(), L"add/remove/mark methods failed",			   Error::TEST, __FILE__, __LINE__);    }        if (pos_queue_4.peek()->ne(*items[9]) || pos_queue_4.length() != 9) {      return Error::handle(name(), L"add/remove/mark methods failed",			   Error::TEST, __FILE__, __LINE__);    }  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //--------------------------------------------------------------------------  //  // 6. class-specific public methods:  //  queue computation methods  //  //--------------------------------------------------------------------------    // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: queue computation methods...\n");    Console::increaseIndention();  }    // testing the sort/apply/reverse methods for reference mode  //  Char** low_chars = new Char*[num_elem];  for (long i = 0; i < num_elem; i++) {    low_chars[i] = new Char(*items[i]);  }    Char** up_chars = new Char*[num_elem];  for (long i = 0; i < num_elem; i++) {    up_chars[i] = new Char(*items[i]);  }    // initialize queues and Char objects to use for testing  //  Queue<Char> char_queue_1;  Queue<Char> char_queue_2;  Queue<Char> char_queue_3;  Queue<Char> char_queue_4;  Queue<Char> temp_queue;    // add all of the lower case characters to the first queue 'a' - 'z'  //  char_queue_1.add(low_chars, num_elem);    // create an upper case version of these in the second queue 'A' - 'Z'  //  char_queue_2.add(up_chars, num_elem);  char_queue_2.apply(&Char::toUpper);    // add all of the lower case elements to the third queue and upcase them  // 'A' - 'Z'  //  char_queue_3.apply(&Char::toUpper, char_queue_1);    // the third queue should be the same as the second queue now  //  if (char_queue_2.ne(char_queue_3)) {    return Error::handle(name(), L"apply", Error::TEST, __FILE__,			 __LINE__);  }    // create an upper case queue in reverse order in the fourth queue  // 'Z' - 'A'  //  for (long i = 0; i < num_elem; i++) {    char_queue_4.add(items[num_elem - i - 1]);  }  char_queue_4.apply(&Char::toUpper);    // reverse the order of the third queue   //  char_queue_3.reverse();    // the third queue should be the same as the fourth queue now  //  if (char_queue_3.ne(char_queue_4)) {    return Error::handle(name(), L"reverseElement", Error::TEST, __FILE__,			 __LINE__);  }    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //--------------------------------------------------------------------------  //  // 7. class-specific public methods:  //  queue element ordering methods  //  //--------------------------------------------------------------------------    // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: queue element ordering methods...\n");    Console::increaseIndention();  }    // sort  //  char_queue_3.sort();  char_queue_4.sort(Integral::ASCENDING, Queue<Char>::INSERTION);    // all these three queues should be 'A' to 'Z'  //  if (char_queue_3.ne(char_queue_2) || char_queue_4.ne(char_queue_2)) {    return Error::handle(name(), L"sort", Error::TEST, __FILE__,			 __LINE__);  }    // see if the fourth queue contains the letter 'm'  //  char_queue_4.apply(&Char::toLower);  if (!char_queue_4.contains(items[12])) {    return Error::handle(name(), L"contains", Error::TEST, __FILE__,			 __LINE__);  }    // make sure that 'A' is the current item  //  if (char_queue_4.peek()->ne(*items[0])) {    return Error::handle(name(), L"contains", Error::TEST, __FILE__,			 __LINE__);  }    // test the find method  //  if (!char_queue_4.find(items[12])) {    return Error::handle(name(), L"find", Error::TEST, __FILE__,			 __LINE__);  }  // make sure that items[12] is marked  //  if (char_queue_4.getMark()->ne(*items[12])) {    return Error::handle(name(), L"find", Error::TEST, __FILE__,			 __LINE__);  }    {    // testing the sort/apply/reverse methods for self-allocation mode    //    Queue<Char> char_queue_1(USER);    Queue<Char> char_queue_2(USER);    Queue<Char> char_queue_3(USER);    Queue<Char> char_queue_4(USER);    Queue<Char> temp_queue(USER);        // add all of the lower case characters to the first queue 'a' - 'z'    //    char_queue_1.add(low_chars, num_elem);        // create an upper case version of these in the second queue 'A' - 'Z'    //    char_queue_2.add(up_chars, num_elem);    char_queue_2.apply(&Char::toUpper);        // add all of the lower case elements to the third queue and upcase them    // 'A' - 'Z'    //    char_queue_3.apply(&Char::toUpper, char_queue_1);        // the third queue should be the same as the second queue now    //    if (char_queue_2.ne(char_queue_3)) {      return Error::handle(name(), L"apply", Error::TEST, __FILE__,			   __LINE__);    }        // create an upper case queue in reverse order in the fourth queue    // 'Z' - 'A'    //    for (long i = 0; i < num_elem; i++) {      char_queue_4.add(items[num_elem - i - 1]);    }    char_queue_4.apply(&Char::toUpper);        // reverse the order of the third queue     //    char_queue_3.reverse();        // the third queue should be the same as the fourth queue now    //    if (char_queue_3.ne(char_queue_4)) {      return Error::handle(name(), L"reverseElement", Error::TEST, __FILE__,			   __LINE__);    }        // sort    //    char_queue_3.sort();    char_queue_4.sort(Integral::ASCENDING, Queue<Char>::INSERTION);        // all these three queues should be 'A' to 'Z'    //    if (char_queue_3.ne(char_queue_2) || char_queue_4.ne(char_queue_2)) {      return Error::handle(name(), L"sort", Error::TEST, __FILE__,			   __LINE__);    }        // see if the fourth queue contains the letter 'm'    //    char_queue_4.apply(&Char::toLower);    if (!char_queue_4.contains(items[12])) {      return Error::handle(name(), L"contains", Error::TEST, __FILE__,			   __LINE__);    }        // make sure that 'A' is the current item    //    if (char_queue_4.peek()->ne(*items[0])) {      return Error::handle(name(), L"contains", Error::TEST, __FILE__,			   __LINE__);    }      }    // clean up memory  //  for (long i = 0; i < num_elem; i++) {    delete items[i];    delete up_chars[i];    delete low_chars[i];  }  delete [] items;  delete [] up_chars;  delete [] low_chars;  delete tmp_char_ptr;    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 8. print completion message  //  //---------------------------------------------------------------------------    // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    // possibly print completion message  //  if (level_a > Integral::NONE) {    String output(L"diagnostics completed successfully for class ");    output.concat(name());    output.concat(L"\n");    Console::put(output);  }    // exit gracefully  //  return true;}// end of include file//#endif

⌨️ 快捷键说明

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