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

📄 doublelinkedlistdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 4 页
字号:
  }  for (long i = 0; i < 4; i++) {    if (!tmp_list_2(i).assign(*items[i])) {      return Error::handle(name(), L"operator", Error::TEST,			   __FILE__, __LINE__);    }  }  // test getPosition  //  if (tmp_list_2.getPosition() != 1) {    return Error::handle(name(), L"getPosition", Error::TEST, __FILE__,			 __LINE__);  }  // test gotoPosition for all cases  //  for (long i = 0; i < 4; i++) {    tmp_list_2.gotoPosition(i);    if (tmp_list_2.getPosition() != i) {      return Error::handle(name(), L"getPosition", Error::TEST, __FILE__,			   __LINE__);    }  }  // test the contains method  //  tmp_list_2.gotoLast();  for (long i = 0; i < 4; i++) {    if (!tmp_list_2.contains(items[i])) {      return Error::handle(name(), L"contains", Error::TEST, __FILE__,			   __LINE__);    }  }  tmp_list_2.gotoLast();  for (long i = 0; i < 4; i++) {    if (!tmp_list_2.find(items[i])) {      return Error::handle(name(), L"find", Error::TEST, __FILE__,			   __LINE__);    }    if (tmp_list_2.getPosition() != i) {      return Error::handle(name(), L"getPosition", Error::TEST, __FILE__,			   __LINE__);    }  }  // restore the position  //  tmp_list_2.gotoPosition(1);  // set the element of the current node  //  tmp_list_2.remove();  tmp_list_2.gotoPrev();  tmp_list_2.insert(items[4]);  tmp_list_2.setMark();    item_ptr = tmp_list_2.getCurr();  if ((item_ptr == (Char*)NULL) || item_ptr->ne(*items[4])) {    return Error::handle(name(), L"getCurr", Error::TEST, __FILE__,			 __LINE__);  }    // get the item of the first node  //  note now the contents of the list are 0423  //  item_ptr = tmp_list_2.getFirst();  if ((item_ptr == (Char*)NULL) || item_ptr->ne(*items[0])) {    return Error::handle(name(), L"getFirst", Error::TEST, __FILE__,			 __LINE__);  }    // get the item of the last node  //  item_ptr = tmp_list_2.getLast();  if ((item_ptr == (Char*)NULL) || item_ptr->ne(*items[3])) {    return Error::handle(name(), L"getLast", Error::TEST, __FILE__,			 __LINE__);  }    // get the item of the marked node, which is at the third node  //    item_ptr = tmp_list_2.getMark();  if ((item_ptr == (Char*)NULL) || item_ptr->ne(*items[4])) {    return Error::handle(name(), L"getMark", Error::TEST, __FILE__,			 __LINE__);  }    // get the item of the previous and next node   //    item_ptr = tmp_list_2.getPrev();  if ((item_ptr == (Char*)NULL) || item_ptr->ne(*items[0])) {    return Error::handle(name(), L"getPrev", Error::TEST, __FILE__,			 __LINE__);  }    item_ptr = tmp_list_2.getNext();  if ((item_ptr == (Char*)NULL) || item_ptr->ne(*items[2])) {    return Error::handle(name(), L"getNext", Error::TEST, __FILE__,			 __LINE__);  }    // when there is no previous node, getPrev should return false  //  tmp_list_2.gotoFirst();  if (tmp_list_2.getPrev() != (Char*)NULL) {    return Error::handle(name(), L"getPrev", Error::TEST, __FILE__,			 __LINE__);  }    // when there is no next node, getNext should return false  //  tmp_list_2.gotoLast();  if (tmp_list_2.getNext() != (Char*)NULL) {    return Error::handle(name(), L"getNext", Error::TEST, __FILE__,			 __LINE__);  }    // clear mark  //  tmp_list_2.clearMark();    if (tmp_list_2.gotoMark()) {    return Error::handle(name(), L"clearMark", Error::TEST, __FILE__,			 __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //--------------------------------------------------------------------------  //  // 5. class-specific public methods:  //     insert and remove methods  //  //--------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: insert and remove methods...\n");    Console::increaseIndention();  }  // test the insert last method on an empty list in system mode  //  DoubleLinkedList<Char> tmplist_test_0;  tmplist_test_0.insertLast(items[0]);  DoubleLinkedList<Char>* tmplist_test_ptr_0 = new DoubleLinkedList<Char>();    tmplist_test_ptr_0->insertLast(items[0]);  delete tmplist_test_ptr_0;      // test the insert last method on an empty list in user mode  //    DoubleLinkedList<Char> tmplist_test_1(USER);  tmplist_test_1.insertLast(items[0]);  DoubleLinkedList<Char>* tmplist_test_ptr_1 =    new DoubleLinkedList<Char>(USER);    tmplist_test_ptr_1->insertLast(items[0]);  delete tmplist_test_ptr_1;    // testing item manipulation methods  //  DoubleLinkedList<Char>* list_ptr_0 =    new DoubleLinkedList<Char>(USER);  DoubleLinkedList<Char>* list_ptr_1 =    new DoubleLinkedList<Char>(USER);    // SYSTEM-allocated  //  DoubleLinkedList<Char>* list_ptr_2 = new DoubleLinkedList<Char>;    // insertFirst  //  note the numbers in the right-hand comments are indicating the contents  //  of the current list by using their indices in items[]  //  // insert a single item to the beginning of the list  //  list_ptr_0->insertFirst(items[0]);              // 0  list_ptr_0->insertFirst(items[1]);              // 1 0    // we do the same operation on list_ptr_2 as on the list_ptr_0  //  list_ptr_2->insertFirst(items[0]);              // 0  list_ptr_2->insertFirst(items[1]);              // 1 0    if ((list_ptr_0->first_d->getItem()->ne(*items[1])) ||      (list_ptr_0->length() != 2)) {    return Error::handle(name(), L"insertFirst (first_d)", Error::TEST,			 __FILE__, __LINE__);  }    if ((list_ptr_2->first_d->getItem()->ne(*items[1])) ||      (list_ptr_2->length() != 2)) {    return Error::handle(name(), L"insertFirst (first_d)", Error::TEST,			 __FILE__, __LINE__);  }    // curr_d should be the same as the first_d now  //  if (list_ptr_0->curr_d != list_ptr_0->first_d) {    return Error::handle(name(), L"insertFirst (curr_d)", Error::TEST,			 __FILE__, __LINE__);  }    if (list_ptr_2->curr_d != list_ptr_2->first_d) {    return Error::handle(name(), L"insertFirst (curr_d)", Error::TEST,			 __FILE__, __LINE__);  }    // last_d should contain items[0] now  //  if (list_ptr_0->last_d->getItem()->ne(*items[0])) {    return Error::handle(name(), L"insertFirst (last_d)", Error::TEST,			 __FILE__, __LINE__);  }    if (list_ptr_2->last_d->getItem()->ne(*items[0])) {    return Error::handle(name(), L"insertFirst (last_d)", Error::TEST,			 __FILE__, __LINE__);  }    // insert an array of items to the beginning of the list  //  for (long i = 1; i >= 0; i--) {    list_ptr_0->insertFirst(items[i]);        // 01 10    list_ptr_2->insertFirst(items[i]);        // 01 10  }      if ((list_ptr_0->first_d->getItem()->ne(*items[0])) ||      (list_ptr_0->length() != 4)) {    return Error::handle(name(), L"insertFirst (first_d)", Error::TEST,			 __FILE__, __LINE__);  }    if ((list_ptr_2->first_d->getItem()->ne(*items[0])) ||      (list_ptr_2->length() != 4)) {    return Error::handle(name(), L"insertFirst (first_d)", Error::TEST,			 __FILE__, __LINE__);  }    // curr_d should be the same as the first_d now  //  if (list_ptr_0->curr_d != list_ptr_0->first_d) {    return Error::handle(name(), L"insertFirst (curr_d)", Error::TEST,			 __FILE__, __LINE__);  }    if (list_ptr_2->curr_d != list_ptr_2->first_d) {    return Error::handle(name(), L"insertFirst (curr_d)", Error::TEST,			 __FILE__, __LINE__);  }      // move the current node pointer to the end of the list  //  list_ptr_0->gotoLast();  list_ptr_2->gotoLast();    // insert a single item to the list (the curr_d is at the end of the list now)   //  list_ptr_0->insert(items[3]);                      // 0110 3  list_ptr_2->insert(items[3]);                      // 0110 3      if ((list_ptr_0->curr_d->getItem()->ne(*items[3])) ||      (list_ptr_0->length() != 5)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if ((list_ptr_2->curr_d->getItem()->ne(*items[3])) ||      (list_ptr_2->length() != 5)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    // the curr_d should be the same as the last_d now  //  if (list_ptr_0->curr_d != list_ptr_0->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_2->curr_d != list_ptr_2->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    // insert an array of items to the list (the curr_d is at the end of the  // list now)   //  for (long i = 0; i < 3; i++) {    list_ptr_0->insert(items[i]);                // 01103 012    list_ptr_2->insert(items[i]);                // 01103 012  }    if ((list_ptr_0->curr_d->getItem()->ne(*items[2])) ||      (list_ptr_0->length() != 8)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if ((list_ptr_2->curr_d->getItem()->ne(*items[2])) ||      (list_ptr_2->length() != 8)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    // the curr_d should be the same as the last_d now  //  if (list_ptr_0->curr_d != list_ptr_0->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_2->curr_d != list_ptr_2->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    // move the current node pointer to somewhere inside the list  //  list_ptr_0->gotoPrev();  list_ptr_2->gotoPrev();    // insert a single item to the middle of the list  //  list_ptr_0->insert(items[3]);                      // 0110301 3 2  list_ptr_2->insert(items[3]);                      // 0110301 3 2    if ((list_ptr_0->curr_d->getItem()->ne(*items[3])) ||      (list_ptr_0->length() != 9)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if ((list_ptr_2->getCurr()->ne(*items[3])) ||      (list_ptr_2->length() != 9)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_0->getNext()->ne(*items[2])) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_2->getNext()->ne(*items[2])) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    // insert an array of items to the middle of the list  //  for (long i = 0; i < 2; i++) {    list_ptr_0->insert(items[i]);                       // 01103013 01 2    list_ptr_2->insert(items[i]);                       // 01103013 01 2  }    if ((list_ptr_0->getCurr()->ne(*items[1])) ||      (list_ptr_0->length() != 11)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if ((list_ptr_2->getCurr()->ne(*items[1])) ||      (list_ptr_2->length() != 11)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_0->getNext()->ne(*items[2])) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_2->getNext()->ne(*items[2])) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    // insert a single item to the end of the list  //   list_ptr_0->insertLast(items[4]);                   // 01103013012 4  list_ptr_2->insertLast(items[4]);                   // 01103013012 4    if ((list_ptr_0->curr_d->getItem()->ne(*items[4])) ||      (list_ptr_0->length() != 12)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if ((list_ptr_2->curr_d->getItem()->ne(*items[4])) ||      (list_ptr_2->length() != 12)) {    return Error::handle(name(), L"insert (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_0->curr_d != list_ptr_0->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_2->curr_d != list_ptr_2->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    // insert an array of items to the end of the list  //   for (long i = 0; i < 3; i++) {    list_ptr_0->insertLast(items[i]);           // 011030130124 012    list_ptr_2->insertLast(items[i]);           // 011030130124 012  }    if ((list_ptr_0->curr_d->getItem()->ne(*items[2])) ||      (list_ptr_0->length() != 15)) {    return Error::handle(name(), L"insertLast (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if ((list_ptr_2->curr_d->getItem()->ne(*items[2])) ||      (list_ptr_2->length() != 15)) {    return Error::handle(name(), L"insertLast (curr_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_0->curr_d != list_ptr_0->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_2->curr_d != list_ptr_2->last_d) {    return Error::handle(name(), L"insert (last_d)", Error::TEST, __FILE__,			 __LINE__);  }    // prepare a sub list to insert into another list  // and also test the insert method when curr_d is at the beginning of the list  //  list_ptr_1->insert(items[4]);                   // 4  for (long i = 0; i < 4; i++) {    list_ptr_1->insert(items[i]);             // 4 0123  }    list_ptr_1->gotoFirst();  if (list_ptr_1->getFirst()->ne(*items[4]) ||      list_ptr_1->getCurr()->ne(*items[4]) ||      list_ptr_1->first_d->getItem()->ne(*items[4]) ||      (list_ptr_1->length() != 5)) {    return Error::handle(name(), L"insert (2nd)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_1->getNext()->ne(*items[0])) {    return Error::handle(name(), L"insert (2nd)", Error::TEST, __FILE__,			 __LINE__);  }    if (list_ptr_1->getLast()->ne(*items[3])) {    return Error::handle(name(), L"insert (2nd)", Error::TEST, __FILE__,			 __LINE__);  }    // mark a node  //  list_ptr_0->gotoFirst();                      // 0 11030130124012  list_ptr_0->setMark();                        // ^       list_ptr_2->gotoFirst();                      // 0 11030130124012  list_ptr_2->setMark();                        // ^       // insert a list into the beginning of another list  //  list_ptr_0->insertFirst(*list_ptr_1);           // 40123 011030130124012  list_ptr_2->insertFirst(*list_ptr_1);           // 40123 011030130124012    if (list_ptr_0->getFirst()->ne(*items[4]) ||      (list_ptr_0->length() != 20)) {    return Error::handle(name(), L"insertFirst(list)", Error::TEST, __FILE__,			 __LINE__);

⌨️ 快捷键说明

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