void Dbtup::fireDetachedTriggers(KeyReqStruct *req_struct, DLList<TupTriggerData>& triggerList, Operationrec* const regOperPtr, bool disk) { TriggerPtr trigPtr; /** * Set disk page */ req_struct->m_disk_page_ptr.i = m_pgman.m_ptr.i; ndbrequire(regOperPtr->is_first_operation()); triggerList.first(trigPtr); while (trigPtr.i != RNIL) { jam(); if ((trigPtr.p->monitorReplicas || regOperPtr->op_struct.primary_replica) && (trigPtr.p->monitorAllAttributes || trigPtr.p->attributeMask.overlaps(req_struct->changeMask))) { jam(); executeTrigger(req_struct, trigPtr.p, regOperPtr, disk); } triggerList.next(trigPtr); } }
int main(int argc, char *argv[]) { DLList<scalar> myList; for (int i = 0; i<10; i++) { myList.append(1.3*i); } myList.append(100.3); myList.append(500.3); Info<< nl << "And again using STL iterator: " << nl << endl; forAllIter(DLList<scalar>, myList, iter) { Info<< "element:" << *iter << endl; } Info<< nl << "And again using the same STL iterator: " << nl << endl; forAllIter(DLList<scalar>, myList, iter) { Info<< "Removing " << myList.remove(iter) << endl; }
void test1() { DLList list; list << 1 << 2 << 12 << 13 << 11 << 22; std::cout<<"List:"<<std::endl; list.print(); }
void testPart4(BinarySearchTree<BSTNode1<int>, int> *tree) { cout << "Testing Part 4..." << endl; cout << "______________________________" << endl; DLList<int> list = tree->getLE(10); cout << "All items in tree less than 10: "; for(int n = 1; n < list.size(); n++){ cout << list.get(n) << ", "; } cout << endl; }
//Method for reversing a list in place. void reverseList(){ DLList newList; while (head != NULL) { newList.newNodeAtFront(this -> head -> data); head = head -> next; } head = newList.head; tail = newList.tail; }
void test4() { DLList list; list << 1 << 1 << 2 << 3 << 5 << 8 << 13 << 21 << 34 << 55 << 89; std::cout<<"List:"<<std::endl; list.print(); std::cout<<std::endl<<"Sorted list:"<<std::endl; list.printSorted(); std::cout<<std::endl<<"List:"<<std::endl; list.print(); }
bool part4test(){ BinarySearchTree<BSTNode1<int>,int> part4; part4.add(20); part4.add(10); part4.add(30); part4.add(5); part4.add(15); part4.getLE(31); DLList<int> list = part4.getLE(13); DLList<int> list2 = part4.getLE(20); return (list.get(0)==5)&&(list.get(1)==10)&& (list2.get(0)==5)&&(list2.get(1)==10)&&(list2.get(2)==15)&&(list2.get(3)==20); }
void test3() { DLList list; int dave; list << 1 << 1 << 1 << 0 << 0 << 12 << 123123; std::cout<<"List:"<<std::endl; list.print(); std::cout<<std::endl<<"Removing last index..."<<std::endl<<std::endl; std::cout<<"List:"<<std::endl; bool saved = list.removeLast(dave); list.print(); std::cout<<std::endl; std::cout<<"Removed element: "<<dave<<std::endl; std::cout<<"Success? "<<((saved) ? "Yes." : "No.")<<std::endl; }
// // I_AddDeferredEvent // // haleyjd 03/06/13: Some received input events need to be deferred until at // least one tic has passed before they are posted to the event queue. // "Trigger" style keys such as mousewheel up and down are the chief offenders. // Rather than shoehorning a bunch of code for this into I_GetEvent, it is // now handled here uniformly for all event types. // static void I_AddDeferredEvent(const event_t &ev, int tic) { deferredevent_t *de; if(i_deferredfreelist.head) { de = *i_deferredfreelist.head; i_deferredfreelist.remove(de); } else de = estructalloc(deferredevent_t, 1); de->ev = ev; de->tic = tic; i_deferredevents.insert(de); }
void Dbtup::executeTriggers(KeyReqStruct *req_struct, DLList<TupTriggerData>& triggerList, Operationrec* regOperPtr, bool disk) { TriggerPtr trigPtr; triggerList.first(trigPtr); while (trigPtr.i != RNIL) { jam(); executeTrigger(req_struct, trigPtr.p, regOperPtr, disk); triggerList.next(trigPtr); } }
void processFile (string filename) { DLList list; stringstream ss; ifstream fin(filename.c_str()); if(!fin.fail()) { string nextline; while(!fin.eof()) { getline(fin, nextline); if(isalpha(nextline[0])) { list.insert(nextline); } else { list.cycle(atoi(nextline.c_str())); cout << list.ToString() <<endl << "Won this round" << endl; cout << list.getDeleted() << endl << "loses this round. " << endl << endl; } } cout <<"Congratulations to: " << list.getFront() << endl << "you won!" << endl; fin.close(); list.clear(); cout << "INPUT FINISHED" << endl; } else { cout << "Unable to open " << filename << " for processing." << endl; } }
/********************************************************************** * Fib - setFibNumber * Inputs: n (int) * Calculates the n-th Fibonacci number ***********************************************************************/ void Fib::setFibNumber(int n) { if (n < 1) { cout << "Fibonacci subscript cannot be less than 1\n"; return; } /*need to clear fibNumber. setFibNumber() may be called several times on an object and you would have problems if you didn't erase all previous data*/ fibNumber.clear(); fibNumber.insert(1,0); // fibNumber will start as f1. f1 = 1; fibSubscript = n; if (n < 3) // can return here if n is 1 or 2. return; DLList<int> f2; f2.insert(1,0); // fibNumber(aka f1) = 1 and f2 = 1. We are rdy to start. Node<int>* p1;// traversal pointers for DLList objects fibNumber(f1) and f2 Node<int>* p2; int temp = 0; // used as f1's node value placeholder. int carry = 0; for (int i = 0; i < n - 2; i++) //run n - 2 times. f1 and f2 done already { //reset pointers to respective beginnings of lists. reset carry to 0 p1 = fibNumber.getFirstNode(); p2 = f2.getFirstNode(); carry = 0; //Add both lists. fibNumber becomes sum, f2 becomes what fibNumber was while (p1 != NULL) { temp = p1->getData(); p1->setData((p1->getData() + p2->getData() + carry) % 1000000000); carry = (temp + p2->getData()) / 1000000000; p2->setData(temp); p1 = p1->getNext(); p2 = p2->getNext(); } if (carry == 1) // Account for carry on addition of final nodes. { fibNumber.insert(1, fibNumber.getNumItems()); f2.insert(0, f2.getNumItems()); } } }
void TestBinarySearchTreeGetLE() { BinarySearchTree<BSTNode1<int>, int> b; b.add(4); b.add(2); b.add(5); b.add(1); b.add(3); b.add(6); DLList<int> l = b.getLE(3); assert(l.contains(1)); assert(l.contains(2)); assert(l.contains(3)); assert(!l.contains(4)); assert(!l.contains(5)); assert(!l.contains(6)); }
/* ---------------------------------------------------------------- */ Uint32 Dbtup::dropTrigger(Tablerec* table, const DropTrigReq* req, BlockNumber sender) { if (ERROR_INSERTED(4004)) { CLEAR_ERROR_INSERT_VALUE; return 9999; } Uint32 triggerId = req->getTriggerId(); TriggerType::Value ttype = req->getTriggerType(); TriggerActionTime::Value ttime = req->getTriggerActionTime(); TriggerEvent::Value tevent = req->getTriggerEvent(); // ndbout_c("Drop TupTrigger %u = %u %u %u %u by %u", triggerId, table, ttype, ttime, tevent, sender); DLList<TupTriggerData>* tlist = findTriggerList(table, ttype, ttime, tevent); ndbrequire(tlist != NULL); Ptr<TupTriggerData> ptr; for (tlist->first(ptr); !ptr.isNull(); tlist->next(ptr)) { jam(); if (ptr.p->triggerId == triggerId) { if(ttype==TriggerType::SUBSCRIPTION && sender != ptr.p->m_receiverBlock) { /** * You can only drop your own triggers for subscription triggers. * Trigger IDs are private for each block. * * SUMA encodes information in the triggerId * * Backup doesn't really care about the Ids though. */ jam(); continue; } jam(); tlist->release(ptr.i); return 0; } } return DropTrigRef::TriggerNotFound; }//Dbtup::dropTrigger()
void Maze_Assign::CreateMaze(int dim1, int dim2) { for (int i = 0; i < dim1; i++) { for (int j = 0; j < dim2; j++) { Maze.newNodeAtEnd("..."); } } //Maze.printlist(); }
void Dbtup::fireDeferredTriggers(Signal* signal, KeyReqStruct *req_struct, DLList<TupTriggerData>& triggerList, Operationrec* const regOperPtr) { TriggerPtr trigPtr; triggerList.first(trigPtr); while (trigPtr.i != RNIL) { jam(); if (trigPtr.p->monitorAllAttributes || trigPtr.p->attributeMask.overlaps(req_struct->changeMask)) { jam(); executeTrigger(req_struct, trigPtr, regOperPtr); }//if triggerList.next(trigPtr); }//while }//Dbtup::fireDeferredTriggers()
void test5() { DLList list1, list2; for (int x = 0; x < 100; ++x) { if (x % 4 == 0) list1 << x; if (x % 5 == 0) list2 << x; } std::cout<<"List1:"<<std::endl; list1.print(); std::cout<<std::endl; std::cout<<"List2:"<<std::endl; list2.print(); std::cout<<std::endl; std::cout<<"Intersection:"<<std::endl; DLList * intersect = list1.intersection(list2); intersect->print(); delete intersect; }
//- merge the input list, merge_list, with the current list, making //- sure not to add duplicate items into the current list void DLList::merge_unique ( DLList& merge_list, int merge_list_unique ) { // MJP Note: // This procedure could be much more efficient if sorted lists // are used. However, I need this procedure at this time to merge // DLLists that already exist. These were not created as sorted // lists (SDLLists) and it would be painful to convert them to // SDLLists. It would be a lot easier if one could simply sort // a DLList based on the numeric values of its items. // Save the current index of the merge_list int current_index = merge_list.index; int old_size = size(); int i, j, check_index; void* new_item = NULL; for (i = 0; i < merge_list.size(); i++) { // Get the item from the merge_list and insert it into "this" // list if it doesn't already exist there. new_item = merge_list.get_item_and_step(); check_index = merge_list_unique ? old_size : size(); for ( j = 0; j < check_index; j++ ) { if ( listArray[j] == new_item ) { check_index = -1; break; } } if ( check_index != -1 ) append_link(new_item); } // Restore the original index of the merge_list merge_list.index = current_index; }
void LRUCache::fetchPage(int pageNumber) { /* find the page in the map */ unordered_map< int, Node* >::const_iterator it = directAccess.find(pageNumber); /* if the page is found in the map */ if (it != directAccess.end()) { /* move the page on to the head of the doubly list */ dlist.moveToHead( (Node*)it->second); } else { /* if size of list is full */ if (dlist.size() == cacheSize-1) dlist.removeTail(); /* add the node to the head of doubly list */ Node* node = dlist.addNode(pageNumber); /* add the node in the map */ directAccess.insert(pair< int, Node* >(pageNumber,node)); } dlist.print(); }
/********************************************************************** * Fib::display() - Displays the Fibonacci number. ***********************************************************************/ void Fib::display() { if (fibSubscript == 0) { cout << "Use setFibNumber() to initialize object\n"; return; } Node<int>* trav = fibNumber.getFirstNode(); while (trav->getNext() != NULL) // traverse to the end of the list trav = trav->getNext(); cout << trav->getData();//display most significant node without setw/setfill trav = trav->getPrevious(); while (trav != NULL) //traverse list in reverse and display w/ setw/setfill { cout << setw(9) << setfill('0') << trav->getData(); trav = trav->getPrevious(); } }
// Efficiently Computing Static Single Assignment Form and // the Control Dependence Graph, // R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, F. K. Zadeck bool Function::convertToSSA() { // 0. calculate live in variables (for pruned SSA) buildLiveSets(); // 1. create the dominator tree domTree = new DominatorTree(&cfg); reinterpret_cast<DominatorTree *>(domTree)->findDominanceFrontiers(); // 2. insert PHI functions DLList workList; LValue *lval; BasicBlock *bb; int var; int iterCount = 0; int *hasAlready = new int[allBBlocks.getSize() * 2]; int *work = &hasAlready[allBBlocks.getSize()]; memset(hasAlready, 0, allBBlocks.getSize() * 2 * sizeof(int)); // for each variable for (var = 0; var < allLValues.getSize(); ++var) { if (!allLValues.get(var)) continue; lval = reinterpret_cast<Value *>(allLValues.get(var))->asLValue(); if (!lval || lval->defs.empty()) continue; ++iterCount; // TODO: don't add phi functions for values that aren't used outside // the BB they're defined in // gather blocks with assignments to lval in workList for (Value::DefIterator d = lval->defs.begin(); d != lval->defs.end(); ++d) { bb = ((*d)->getInsn() ? (*d)->getInsn()->bb : NULL); if (!bb) continue; // instruction likely been removed but not XXX deleted if (work[bb->getId()] == iterCount) continue; work[bb->getId()] = iterCount; workList.insert(bb); } // for each block in workList, insert a phi for lval in the block's // dominance frontier (if we haven't already done so) for (DLList::Iterator wI = workList.iterator(); !wI.end(); wI.erase()) { bb = BasicBlock::get(wI); DLList::Iterator dfIter = bb->getDF().iterator(); for (; !dfIter.end(); dfIter.next()) { Instruction *phi; BasicBlock *dfBB = BasicBlock::get(dfIter); if (hasAlready[dfBB->getId()] >= iterCount) continue; hasAlready[dfBB->getId()] = iterCount; // pruned SSA: don't need a phi if the value is not live-in if (!dfBB->liveSet.test(lval->id)) continue; phi = new_Instruction(this, OP_PHI, typeOfSize(lval->reg.size)); dfBB->insertTail(phi); phi->setDef(0, lval); for (int s = 0; s < dfBB->cfg.incidentCount(); ++s) phi->setSrc(s, lval); if (work[dfBB->getId()] < iterCount) { work[dfBB->getId()] = iterCount; wI.insert(dfBB); } } } } delete[] hasAlready; RenamePass rename(this); return rename.run(); }
void unittest2 () { cout << "\nSTARTING UNIT TEST\n\n"; DLList list; try { evaluate(list.getSize() == 0); cout << "Passed TEST 1: default constructor (size) \n"; } catch (MyException e) { cout << "# FAILED TEST 1: default constructor (size) #\n"; } try { evaluate(list.toString() == ""); cout << "Passed TEST 2: toString \n"; } catch (MyException e) { cout << "# FAILED TEST 2: toString #\n"; } list.insert(10); try { evaluate(list.getSize() == 1 && list.toString() == "10"); cout << "Passed TEST 3: insert(10)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 3: insert(10)/getSize/toString #\n"; } list.insert(50); try { evaluate(list.getSize() == 2 && list.toString() == "10,50"); cout << "Passed TEST 4: insert(50)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 4: insert(50)/getSize/toString #\n"; } list.insert(30); try { evaluate(list.getSize() == 3 && list.toString() == "10,30,50"); cout << "Passed TEST 5: insert(30)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 5: insert(30)/getSize/toString #\n"; } list.insert(5); try { evaluate(list.getSize() == 4 && list.toString() == "5,10,30,50"); cout << "Passed TEST 6: insert(5)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 6: insert(5)/getSize/toString #\n"; } list.insert(55); try { evaluate(list.getSize() == 5 && list.toString() == "5,10,30,50,55"); cout << "Passed TEST 7: insert(55)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 7: insert(55)/getSize/toString #\n"; } list.insert(20); try { evaluate(list.getSize() == 6 && list.toString() == "5,10,20,30,50,55"); cout << "Passed TEST 8: insert(20)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 8: insert(20)/getSize/toString #\n"; } list.insert(40); try { evaluate(list.getSize() == 7 && list.toString() == "5,10,20,30,40,50,55"); cout << "Passed TEST 9: insert(40)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 9: insert(40)/getSize/toString #\n"; } list.insert(30); try { evaluate(list.getSize() == 8 && list.toString() == "5,10,20,30,30,40,50,55"); cout << "Passed TEST 10: insert(30)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 10: insert(30)/getSize/toString #\n"; } list.insert(5); try { evaluate(list.getSize() == 9 && list.toString() == "5,5,10,20,30,30,40,50,55"); cout << "Passed TEST 11: insert(5)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 11: insert(5)/getSize/toString #\n"; } try { evaluate(list.removeFirst(1) == false); cout << "Passed TEST 12: removeFirst(1) \n"; } catch (MyException e) { cout << "# FAILED TEST 12: removeFirst(1) #\n"; } try { evaluate(list.removeFirst(5) == true && list.getSize() == 8 && list.toString() == "5,10,20,30,30,40,50,55"); cout << "Passed TEST 13: removeFirst(5)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 13: removeFirst(5)/getSize/toString #\n"; } try { evaluate(list.removeFirst(30) == true && list.getSize() == 7 && list.toString() == "5,10,20,30,40,50,55"); cout << "Passed TEST 14: removeFirst(30)/getSize/toString \n"; } catch (MyException e){ cout << "# FAILED TEST 14: removeFirst(30)/getSize/toString #\n"; } try { evaluate(list.removeFirst(30) == true && list.getSize() == 6 && list.toString() == "5,10,20,40,50,55"); cout << "Passed TEST 15: removeFirst(30)/getSize/toString \n"; } catch (MyException e){ cout << "# FAILED TEST 15: removeFirst(30)/getSize/toString #\n"; } try { evaluate(list.removeFirst(55) == true && list.getSize() == 5 && list.toString() == "5,10,20,40,50"); cout << "Passed TEST 16: removeFirst(55)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 16: removeFirst(55)/getSize/toString #\n"; } try { evaluate(list.removeFirst(10) == true && list.getSize() == 4 && list.toString() == "5,20,40,50"); cout << "Passed TEST 17: removeFirst(10)/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 17: removeFirst(10)/getSize/toString #\n"; } list.popFront(); try { evaluate(list.getSize() == 3 && list.toString() == "20,40,50"); cout << "Passed TEST 18: removeHead/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 18: removeHead/getSize/toString #\n"; } list.popBack(); try { evaluate(list.getSize() == 2 && list.toString() == "20,40"); cout << "Passed TEST 19: removeTail/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 19: removeTail/getSize/toString #\n"; } list.clear(); try { evaluate(list.getSize() == 0 && list.toString() == ""); cout << "Passed TEST 20: clear/getSize/toString \n"; } catch (MyException e) { cout << "# FAILED TEST 20: clear/getSize/toString #\n"; } cout << "\nUNIT TEST COMPLETE\n\n"; }
void unittest () { cout << "\n STARTING UNIT TEST!!!!!\n\n"; DLList list; DLList list1; DLList list2; try { evaluate (list.getFront() == 0); cout << "Passed TEST 1: getFront '0' pushFront/getFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 1: getFront"; } cout << endl; try { evaluate (list.getSize() == 0); cout << "Passed TEST 2: getSize '0' "; } catch (MyException e) { cout << "#" << e.message << " TEST 2: getSize"; } cout << endl; try { evaluate (list.getBack() == 0); cout << "Passed TEST 3: getBack '0' "; } catch (MyException e) { cout << "#" << e.message << " TEST 3: getBack"; } cout << "\n\n FINISHED TESTING EMPTY LISTS!!!!!\n\n"; list.pushFront(20); list.pushBack(5); list1.pushFront(63); list1.pushBack(12); list2.pushFront(14); list2.pushBack(99); list.insert(44); list1.insert(87); list2.insert(56); try { evaluate (list.getFront() == 20); cout << "Passed TEST 4: getFront '20' pushFront/getFront "; } catch (MyException e) { cout << "#" << e.message << " TEST 4: getFront '20' pushFront/getFront"; } cout << endl; try { evaluate (list1.getFront() == 63); cout << "Passed TEST 5: getFront '63' pushFront/getFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 5: getFront '63' pushFront/getFront"; } cout << endl; cout << list2.getFront() << endl; try { evaluate (list2.getFront() == 14); cout << "Passed TEST 6: getFront '14' pushFront/getFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 6: getFront '14' pushFront/getFront"; } cout << endl; try { evaluate (list.getBack() == 5); cout << "Passed TEST 7: getBack '5' pushBack/getBack"; } catch (MyException e) { cout << "#" << e.message << " TEST 7: getBack '5' pushBack/getBack"; } cout << endl; try { evaluate (list1.getBack() == 12); cout << "Passed TEST 8: getBack '12' pushBack/getBack"; } catch (MyException e) { cout << "#" << e.message << " TEST 8: getBack '12' pushBack/getBack"; } cout << endl; try { evaluate (list2.getBack() == 99); cout << "Passed TEST 9: getBack '99' pushBack/getBack"; } catch (MyException e) { cout << "#" << e.message << " TEST 9: getBack '99' pushBack/getBack"; } cout << endl; cout << "\n FINISHED TESTING push/get-Back/Front!!!!!\n\n"; try { evaluate (list.get(20) == true); cout << "Passed TEST 10: get '20' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 10: get '20' get(target)"; } cout << endl; try { evaluate (list1.get(63) == true); cout << "Passed TEST 11: get '63' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 11: get '63' get(target"; } cout << endl; try { evaluate (list2.get(14) == true); cout << "Passed TEST 12: get '14' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 12: get '14' get(target)"; } cout << endl; try { evaluate (list.get(5) == true); cout << "Passed TEST 13: get '5' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 13: get '5' get(target)"; } cout << endl; try { evaluate (list1.get(12) == true); cout << "Passed TEST 14: get '12' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 14: get '12' get(target)"; } cout << endl; try { evaluate (list2.get(99) == true); cout << "Passed TEST 15: get '99' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 15: get '99' get(target)"; } cout << endl; try { evaluate (list.get(1) == false); cout << "Passed TEST 16: get '1' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 16: get '1' get(target)"; } cout << endl; try { evaluate (list1.get(2) == false); cout << "Passed TEST 17: get '2' get(target"; } catch (MyException e) { cout << "#" << e.message << " TEST 17: get '2' get(target)"; } cout << endl; try { evaluate (list2.get(3) == false); cout << "Passed TEST 18: get '3' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 18: get '3' get(target)"; } cout << endl; try { evaluate (list.get(44) == true); cout << "Passed TEST 19: get '44' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 19: get '44' get(target)"; } cout << endl; try { evaluate (list1.get(87) == true); cout << "Passed TEST 20: get '87' get(target"; } catch (MyException e) { cout << "#" << e.message << " TEST 20: get '87' get(target)"; } cout << endl; try { evaluate (list2.get(56) == true); cout << "Passed TEST 21: get '56' get(target)"; } catch (MyException e) { cout << "#" << e.message << " TEST 21: get '56' get(target)"; } cout << endl; DLList list3; list3.pushFront(4); list3.pushFront(5); list3.pushFront(6); list3.pushFront(7); list3.popFront(); try { evaluate (list3.getFront() == 6); cout << "Passed TEST 22: popFront '6' popBack/popFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 22: popFront '6' popBack/popFront"; } cout << endl; list3.popFront(); try { evaluate (list3.getFront() == 5); cout << "Passed TEST 23: popFront '5' popBack/popFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 23: popFront '5' popBack/popFront"; } cout << endl; list3.popFront(); try { evaluate (list3.getFront() == 4); cout << "Passed TEST 24: popFront '4' popBack/popFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 24: popFront '4' popBack/popFront"; } cout << endl; list3.pushBack(9); list3.pushBack(10); list3.pushBack(11); list3.pushBack(12); list3.popBack(); try { evaluate (list3.getBack() == 11); cout << "Passed TEST 25: popBack '11' popBack/popFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 25: popBack '11' popBack/popFront"; } cout << endl; list3.popBack(); try { evaluate (list3.getBack() == 10); cout << "Passed TEST 26: popBack '10' popBack/popFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 26: popBack '10' popBack/popFront"; } cout << endl; list3.popBack(); try { evaluate (list3.getBack() == 9); cout << "Passed TEST 27: popBack '9' popBack/popFront"; } catch (MyException e) { cout << "#" << e.message << " TEST 27: popBack '9' popBack/popFront"; } cout << endl; cout << "\n FINISHED TESTING get(target)-popBack/popFront!!!!!\n\n"; DLList list4; list4.pushFront(7); list4.pushFront(8); list4.pushFront(9); list4.pushFront(10); list4.pushFront(11); list4.pushFront(12); list4.pushBack(3); try { evaluate (list4.removeFirst(9) == true); cout << "Passed TEST 28: removeFirst '9' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 28: removeFirst '9' removeFirst/removeAll"; } cout << endl; try { evaluate (list4.removeFirst(7) == true); cout << "Passed TEST 29: removeFirst '7' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 28: removeFirst '7' removeFirst/removeAll"; } cout << endl; try { evaluate (list4.removeFirst(15) == false); cout << "Passed TEST 30: removeFirst '15' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 30: removeFirst '15' removeFirst/removeAll"; } cout << endl; try { evaluate (list4.removeFirst(9) == false); cout << "Passed TEST 31: removeFirst '9' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 31: removeFirst '9' removeFirst/removeAll"; } cout << endl; try { evaluate (list4.removeFirst(3) == true); cout << "Passed TEST 32: removeFirst '3' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 32: removeFirst '3' removeFirst/removeAll"; } cout << endl; DLList list5; list5.pushFront(4); list5.pushFront(3); list5.pushFront(7); list5.pushFront(6); list5.pushFront(8); list5.pushFront(7); list5.pushFront(4); list5.pushFront(3); list5.pushFront(7); list5.pushFront(6); list5.pushFront(8); list5.pushFront(7); list5.pushFront(4); list5.pushFront(3); list5.pushFront(7); list5.pushFront(6); list5.pushFront(8); list5.pushFront(7); list5.pushFront(4); list5.pushFront(3); list5.pushFront(7); list5.pushFront(6); list5.pushFront(8); list5.pushFront(7); list5.pushFront(4); list5.pushFront(3); list5.pushFront(7); list5.pushFront(6); list5.pushFront(8); list5.pushFront(7); list5.pushFront(4); list5.pushFront(3); list5.pushFront(7); list5.pushFront(6); list5.pushFront(8); list5.pushFront(7); list5.pushBack(4); list5.pushBack(3); list5.pushBack(7); list5.pushBack(6); list5.pushBack(8); list5.pushBack(7); list5.pushBack(4); list5.pushBack(3); list5.pushBack(7); list5.pushBack(6); list5.pushBack(8); list5.pushBack(7); list5.pushBack(4); list5.pushBack(3); list5.pushBack(7); list5.pushBack(6); list5.pushBack(8); list5.pushBack(7); try { evaluate (list5.removeAll(3) == true); cout << "Passed TEST 33: removeAll '3' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 33: removeAll '3' removeFirst/removeAll"; } cout << endl; try { evaluate (list5.removeAll(7) == true); cout << "Passed TEST 34: removeAll '7' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 34: removeAll '7' removeFirst/removeAll"; } cout << endl; try { evaluate (list5.removeAll(4) == true); cout << "Passed TEST 35: removeAll '4' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 35: removeAll '4' removeFirst/removeAll"; } cout << endl; try { evaluate (list5.removeAll(6) == true); cout << "Passed TEST 36: removeAll '6' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 36: removeAll '6' removeFirst/removeAll"; } cout << endl; try { evaluate (list5.removeAll(8) == true); cout << "Passed TEST 37: removeAll '8' removeFirst/removeAll"; } catch (MyException e) { cout << "#" << e.message << " TEST 37: removeAll '8' removeFirst/removeAll"; } cout << endl; }
void processFile(char* filename) { //set up the input file stream and attempt to open the file ifstream fin; fin.open(filename); //if the file is successfully opened if (!fin.fail()) { //create a Doubly Linked List pointer (set to NULL) DLList* list = NULL; //set up reusable string stream object, int variable, and string nextLine stringstream ss; int value = 0; string nextLine; //while loop that continues until the end of the file is reached while (!fin.eof()){ //get the next line from the file getline(fin, nextLine); //pull the first character from nextLine and make sure it is uppercase char firstCharacter = toupper(nextLine[0]); //if the character is C if (firstCharacter == 'C') { //if there is already a list, delete it first if (list != NULL) { delete list; list = NULL; } //create a new list and output success to the console list = new DLList; cout << "LIST CREATED" << endl; //if the first character is # } else if (firstCharacter == '#') { //do nothing } else { //any operation other than C requires a list instance //if there is no list instance if (list == NULL) { //output requirement to the console cout << "MUST CREATE LIST INSTANCE" << endl; } else { //if there is a list instance perform an operation based on the first character of nextLine switch(firstCharacter) { //if the character is X case 'X': //clear the list and output success to the console list->clear(); cout << "LIST CLEARED" << endl; break; //if the character is D case 'D': //delete the list, set the list pointer to NULL, and output success to the console delete list; list = NULL; cout << "LIST DELETED" << endl; break; //if the character is I case 'I': //get the integer value that follows the character ss.str(nextLine.substr(2)); ss >> value; //insert a Node into the list with the integer value from the input file as contents (ascending order) list->insert(value); //output success to the console cout << "VALUE " << value << " INSERTED" << endl; //clear the stringstream ss.clear(); break; //if the character is F case 'F': //get the integer that follows the character ss.str(nextLine.substr(2)); ss >> value; //insert a Node at the head pointer with the value from the input file as contents list->pushFront(value); //output success to the console cout << "VALUE " << value << " ADDED TO HEAD" << endl; //clear the stringstream ss.clear(); break; //if the character is B case 'B': //get the integer that follows the character ss.str(nextLine.substr(2)); ss >> value; //insert a Node at the tail pointer with the value from the input file as contents list->pushBack(value); //output success to the console cout << "VALUE " << value << " ADDED TO TAIL" << endl; //clear the stringstream ss.clear(); break; //if the character is A case 'A': //attempt to output the value of the Node a the head pointer to the console try { //output success to the console cout << "VALUE " << list->getFront() << " AT HEAD" << endl; //if the attempt is unsuccessful (head is NULL) } catch (string err) { //output failure to the console cout << err << endl; } break; //if the character is Z case 'Z': //attempt to output the value of the Node at the tail pointer to the console try { //output success to the console cout << "VALUE " << list->getBack() << " AT TAIL" << endl; //if the attempt is unsuccessful (tail is NULL) } catch (string err) { //output failure to the console cout << err << endl; } break; //if the character is T case 'T': //if the list is empty if (list->getSize() < 1) { //output failure to the console cout << "LIST EMPTY" << endl; } else { //remove the Node at the head pointer and output success to the console list->popFront(); cout << "REMOVED HEAD" << endl; } break; //if the character is K case 'K': //if the list is empty if (list->getSize() < 1) { //output failure to the console cout << "LIST EMPTY" << endl; } else { //remove the Node at the tail pointer and output success to the console list->popBack(); cout << "REMOVED TAIL" << endl; } break; //if the character is E case 'E': //get the integer that follows the character ss.str(nextLine.substr(2)); ss >> value; //attempt to remove all instances of Nodes with the integer value from the list if (list->removeAll(value) == true) { //output success to the console cout << "VALUE " << value << " ELIMINATED" << endl; } else { //output failure to the console cout << "VALUE " << value << " NOT FOUND" << endl; } //clear the stringstream ss.clear(); break; //if the character is R case 'R': //get the integer value that follows the character ss.str(nextLine.substr(2)); ss >> value; //attempt to remove the first instance of a Node with the integer value from the list if (list->removeFirst(value) == true) { //output success to the console cout << "VALUE " << value << " REMOVED" << endl; } else { //output failure to the console cout << "VALUE " << value << " NOT FOUND" << endl; } //clear the stringstream ss.clear(); break; //if the character is G case 'G': //get the integer value that follows the character ss.str(nextLine.substr(2)); ss >> value; //attempt to locate a Node with the integer value if (list->get(value) == true) { //output success to the console cout << "VALUE " << value << " FOUND" << endl; } else { //output failure to the console cout << "VALUE " << value << " NOT FOUND" << endl; } //clear the stringstream ss.clear(); break; //if the character is N case 'N': //output the number of Nodes in the list cout << "LIST SIZE IS " << list->getSize() << endl; break; //if the character is P case 'P': //if the list is empty if (list->getSize() < 1){ //output failure to the console cout << "LIST EMPTY" << endl; } else { //output the contents of every node in the list, from head to tail cout << *list << endl; } break; } } } } //close the file input stream fin.close(); } else {
int main() { using namespace std; DLList<int> myIntDLL; cout << "Prepending: 5" << endl; myIntDLL.prepend(5); myIntDLL.printList(); cout << "Prepending: 4" << endl; myIntDLL.prepend(4); myIntDLL.printList(); cout << "Prepending: 3" << endl; myIntDLL.prepend(3); myIntDLL.printList(); cout << "Appending: 9" << endl; myIntDLL.append(9); myIntDLL.printList(); cout << "Appending: 8" << endl; myIntDLL.append(8); myIntDLL.printList(); cout << "Appeding: 7" << endl; myIntDLL.append(7); myIntDLL.printList(); cout << "Current data: " << *myIntDLL.getValue() << endl; cout << "Moving to end" << endl; myIntDLL.moveToEnd(); cout << "Current data: " << *myIntDLL.getValue() << endl; cout << "Moving to start" << endl; myIntDLL.moveToStart(); cout << "Current data: " << *myIntDLL.getValue() << endl; cout << "Iterating through list with next function" << endl; for (int i = 0; i < 10; i++) { cout << "Current data: " << *myIntDLL.getValue() << endl; cout << "Next: " << myIntDLL.next() << endl; } cout << "Iterating through list with prev function" << endl; for (int i = 0; i < 10; i++) { cout << "Current data: " << *myIntDLL.getValue() << endl; cout << "Prev: " << myIntDLL.prev() << endl; } cout << "Number of links active: " << myIntDLL.numActive() << endl; cout << "Number of links free: " << myIntDLL.numFree() << endl; cout << "Clearing list" << endl; myIntDLL.clear(); myIntDLL.printList(); cout << "Number of links active: " << myIntDLL.numActive() << endl; cout << "Number of links free: " << myIntDLL.numFree() << endl; return 0; }
int main(int argc, char *argv[]) { if(argc <= 1){ cout << "Error: No command-line argument." << endl; } else{ DLList<int> *intList = NULL; ifstream fileIn(argv[1]); if(!fileIn.good()){ cout << "Error: File could not be opened." << endl; } else{ string line; while(getline(fileIn, line)){ char operation = line[0]; //cout << operation << " : "; if(operation == '#'){ //cout << "COMMENT" << endl; } else if(operation == 'C'){ cout << "LIST CREATED" << endl; if(intList != NULL){ delete intList; } intList = new DLList<int>; } else if(intList == NULL){ cout << "MUST CREATE LIST INSTANCE" << endl; } else{ if(operation == 'X'){ cout << "LIST CLEARED" << endl; intList->clear(); } else if(operation == 'D'){ cout << "LIST DELETED" << endl; delete intList; intList = NULL; } else if(operation == 'A'){ try{ cout << "VALUE " << intList->getFront() << " AT HEAD" << endl; } catch (string e){ cout << e << endl; } } else if(operation == 'Z'){ try{ cout << "VALUE " << intList->getBack() << " AT TAIL" << endl; } catch (string e){ cout << e << endl; } } else if(operation == 'T'){ if(intList->getSize() > 0){ intList->popFront(); cout << "REMOVED HEAD" << endl; } else{ cout << "LIST EMPTY" << endl; } } else if(operation == 'K'){ if(intList->getSize() > 0){ intList->popBack(); cout << "REMOVED TAIL" << endl; } else{ cout << "LIST EMPTY" << endl; } } else if(operation == 'N'){ cout << "LIST SIZE IS " << intList->getSize() << endl; } else if(operation == 'P'){ if(intList->getSize() > 0){ cout << *intList << endl; } else{ cout << "LIST EMPTY" << endl; } } else{ string str = line.substr(2); stringstream ss(str); int value = 0; ss >> value; if(operation == 'I'){ cout << "VALUE " << value << " INSERTED" << endl; intList->insert(value); } else if(operation == 'F'){ cout << "VALUE " << value << " ADDED TO HEAD" << endl; intList->pushFront(value); } else if(operation == 'B'){ cout << "VALUE " << value << " ADDED TO TAIL" << endl; intList->pushBack(value); } else if(operation == 'E'){ if(intList->removeAll(value)){ cout << "VALUE " << value << " ELIMINATED" << endl; } else{ cout << "VALUE " << value << " NOT FOUND" << endl; } } else if(operation == 'R'){ if(intList->removeFirst(value)){ cout << "VALUE " << value << " REMOVED" << endl; } else{ cout << "VALUE " << value << " NOT FOUND" << endl; } } else if(operation == 'G'){ if(intList->get(value)){ cout << "VALUE " << value << " FOUND" << endl; } else{ cout << "VALUE " << value << " NOT FOUND" << endl; } } } } } } if(intList != NULL){ delete intList; intList = NULL; } fileIn.close(); } return 0; }
/*------------------------------------------------------------------------------ * Destroy an element. * Remove an element and destroy it. * @param list List from which remove the element. * @param node Node to remove. ----------------------------------------------------------------------------*/ void DLList_DestroyElement (DLList list, DLListNode node) { ContainerElement elem = DLList_RemoveElement(list, node); if (elem && list->destroyElement) list->destroyElement(elem); }
//############################################################################################################### void reduce_cliques(DLList<ClusterList<NNode*>*> *global_cluster_list, FILE *file) { unsigned long size; ClusterList<NNode*> *c_cur, *largest_c=0; DLList<ClusterList<NNode*>*> *subsets; DLList_Iter<ClusterList<NNode*>*> c_iter, sub_iter; DLList_Iter<NNode*> iter; NNode *n_cur; if (!(global_cluster_list->Size())) return; //wir suchen den groessten Cluster c_cur=c_iter.First(global_cluster_list); size=0; while (!(c_iter.End())) { if (c_cur->Size()>size) { size=c_cur->Size(); largest_c=c_cur; } c_cur=c_iter.Next(); } // printf("Groesster Cluster hat %u Elemente.\n",largest_c->Size()); //Schauen, ob es Teilmengen gibt, die ebenfalls gefunden wurden subsets=new DLList<ClusterList<NNode*>*>(); c_cur=c_iter.First(global_cluster_list); while (!(c_iter.End())) { if ((*c_cur<*largest_c || *c_cur==*largest_c) && c_cur!=largest_c) //alle echten Teilcluster von largest_c und die doppelten { subsets->Push(c_cur); } c_cur=c_iter.Next(); } // die gefundenen Subsets werden aus der cluster_liste geloescht while (subsets->Size()) { global_cluster_list->fDelete(subsets->Pop()); } delete subsets; // Dann schreiben wir den groessten Cluster in das File fprintf(file,"Energie: %1.12f Nodes:%3lu - ",largest_c->Get_Energy(),largest_c->Size()); n_cur=iter.First(largest_c); while (!(iter.End())) { fprintf(file,"%s",n_cur->Get_Name()); n_cur=iter.Next(); if (n_cur) fprintf(file,", "); } fprintf(file,"\n"); //Schliesslich schmeissen wir noch den eben gefundenen groessten Cluster raus global_cluster_list->fDelete(largest_c); //und dann geht es von vorn mit der Reduzierten ClusterListe los reduce_cliques(global_cluster_list, file); }
void processFile(string filename) { ifstream inputstream; DLList *list = NULL; inputstream.open(filename.c_str()); if (inputstream.fail()) { cout << "Unable to open " << filename << " for processing." << endl; } else { string nextline; while (! inputstream.eof()) { stringstream ss; int value = 0; getline(inputstream, nextline); char firstCharacter = nextline[0]; switch (toupper(firstCharacter)) { case 'C': if (list != NULL) { delete list; } list = new DLList; cout << "LIST CREATED" << endl; break; case 'T': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else if (list->getSize() > 0) { list->popFront(); cout << "REMOVED HEAD" << endl; } else { cout << "LIST EMPTY" << endl; } break; case 'I': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { ss.str(nextline.substr(2)); ss >> value; list->insert(value); cout << "VALUE " << value << " INSERTED" << endl; } break; case 'P': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else if (list->getSize() > 0) { cout << (*list) << endl; } else { cout << "LIST EMPTY" << endl; } break; case 'X': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { list->clear(); cout << "LIST CLEARED" << endl; } break; case 'D': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { delete list; list = NULL; cout << "LIST DELETED" << endl; } break; case 'F': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { ss.str(nextline.substr(2)); ss >> value; list->pushFront(value); cout << "VALUE " << value << " ADDED TO HEAD" << endl; } break; case 'B': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { ss.str(nextline.substr(2)); ss >> value; list->pushBack(value); cout << "VALUE " << value << " ADDED TO TAIL" << endl; } break; case 'A': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { try { cout << "VALUE " << list->getFront() << " AT HEAD" << endl; } catch (string e) { cout << e << endl; } } break; case 'Z': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { try { cout << "VALUE " << list->getBack() << " AT TAIL" << endl; } catch (string e) { cout << e << endl; } } break; case 'K': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else if (list->getSize() > 0) { list->popBack(); cout << "REMOVED TAIL" << endl; } else { cout << "LIST EMPTY" << endl; } break; case 'E': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { ss.str(nextline.substr(2)); ss >> value; if (list->removeAll(value) == true) { cout << "VALUE " << value << " ELIMINATED" << endl; } else { cout << "VALUE " << value << " NOT FOUND" << endl; } } break; case 'R': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { ss.str(nextline.substr(2)); ss >> value; if (list->removeFirst(value) == true) { cout << "VALUE " << value << " REMOVED" << endl; } else { cout << "VALUE " << value << " NOT FOUND" << endl; } } break; case 'G': ss.str(nextline.substr(2)); ss >> value; if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else if (list->get(value) == true) { cout << "VALUE " << value << " FOUND" << endl; } else { cout << "VALUE " << value << " NOT FOUND" << endl; } break; case 'N': if (list == NULL) { cout << "MUST CREATE LIST INSTANCE" << endl; } else { cout << "LIST SIZE IS " << list->getSize() << endl; } break; default: break; } } inputstream.close(); } }
void run_project3(string filename){ ifstream myfile(filename.c_str()); if (myfile.is_open()){ string line; string charLetter; bool doesListExist = false; DLList* list; while (getline(myfile,line)){ charLetter = line.at(0); line.erase(0,1); int newNumber = 0; stringstream converter(line); converter >> newNumber; //creating a list. if(charLetter == "C"){ if(doesListExist == false){ list = new DLList; } else if (doesListExist == true){ delete list; list = new DLList; } cout << "LIST CREATED" << endl; doesListExist = true; } //clear the list if there is a list. if(charLetter == "X" && doesListExist == true){ list->clear(); cout << "LIST CLEARED" << endl; } //delete the list if there is a list. if(charLetter == "D" && doesListExist == true){ delete list; list = NULL; cout << "LIST DELETED" << endl; doesListExist = false; } //insert a newNumber into the list if there is list. if(charLetter == "I" && doesListExist == true){ list->insert(newNumber); cout << "VALUE " << newNumber << " INSERTED" << endl; } //add a newNumber into the front of the list if there is list. if(charLetter == "F" && doesListExist == true){ list->pushFront(newNumber); cout << "VALUE " << newNumber << " ADDED TO HEAD" << endl; } //insert a newNumber into the back of the list if there is list. if(charLetter == "B" && doesListExist == true){ list->pushBack(newNumber); cout << "VALUE " << newNumber << " ADDED TO TAIL" << endl; } //get the first element in the list if there is list. if(charLetter == "A" && doesListExist == true){ try{ btassert<bool>(list->getSize() != 0); cout << "VALUE " << list->getFront() << " AT HEAD" << endl; } catch (bool b){ cout << "LIST EMPTY" << endl; } } //get the last element in the list if there is list. if(charLetter == "Z" && doesListExist == true){ try{ btassert<bool>(list->getSize() != 0); cout << "VALUE " << list->getBack() << " AT TAIL" << endl; } catch (bool b){ cout << "LIST EMPTY" << endl; } } //remove element from front of the list if there is a list. if(charLetter == "T" && doesListExist == true){ if(list->getSize() == 0){ cout << "LIST EMPTY" << endl; } else{ list->popFront(); cout << "REMOVED HEAD" << endl; } } //remove element from back of the list if there is a list. if(charLetter == "K" && doesListExist == true){ if(list->getSize() == 0){ cout << "LIST EMPTY" << endl; } else{ list->popBack(); cout << "REMOVED TAIL" << endl; } } //get an element from the list if there is a list. if(charLetter == "G" && doesListExist == true){ if(list->get(newNumber) == true){ cout << "VALUE " << newNumber << " FOUND" << endl; } else{ cout << "VALUE " << newNumber << " NOT FOUND" << endl; } } //eliminate all the same element, the element to be eliminate will be newNumber. if(charLetter == "E" && doesListExist == true){ if(list->removeAll(newNumber) == true){ cout <<"VALUE " << newNumber << " ELIMINATED" << endl; } else{ cout << "VALUE " << newNumber << " NOT FOUND" << endl; } } //remove an element from the list, the element to be remove will be newNumber. if(charLetter == "R" && doesListExist == true){ if(list->removeFirst(newNumber) == true){ cout << "VALUE " << newNumber << " REMOVED" << endl; } else{ cout << "VALUE " << newNumber << " NOT FOUND" << endl; } } //show number of element in the list. if(charLetter == "N" && doesListExist == true){ cout << "LIST SIZE IS " << list->getSize() << endl; } //print the element(s) in the list. if(charLetter == "P" && doesListExist == true){ if(list->getSize() == 0){ cout << "LIST EMPTY" << endl; } else{ cout << *list << endl; } } //display message if there is no list for an operation. if(doesListExist == false && charLetter != "#" && line != ""){ cout << "MUST CREATE LIST INSTANCE" << endl; } } myfile.close(); //delete the list if there is a list before exiting. NULL list pointer. if(doesListExist == true){ delete list; list = NULL; } }