int main(){ LinkedList list; std::cout<<"Teste"<<std::endl; list.insertAtFront(1); list.insertAtFront(2); list.insertAtFront(3); list.insertAtFront(4); printList(list); assert(list.remove(3)); printList(list); assert(list.remove(4)); printList(list); assert(list.remove(1)); printList(list); assert(list.remove(2)); printList(list); assert(list.remove(5) == false); return 0; }
int main(){ LinkedList l = LinkedList(0); l.append(1).append(2).append(2).append(1).append(3).append(4); l.print(); int k = 0; Node* n = l.findKthToLast(k); if(n != nullptr) l.deleteNode(n); l.print(); return 0; }
int main() { LinkedList<std::string> list; list.add("Alice"); list.add("Chuck"); list.add("Elaine"); list.add("fran"); std::cout << "Here are the initial names : " << std::endl; list.displayList(); std::cout << std::endl << std::endl; std::cout << "Now removing Elaine " <<std::endl<<std::endl; list.remove("Elaine"); std::cout << "Here are the remaining elements." << std::endl; list.displayList(); std::cout << std::endl; return 0; }
void SimpleBestFitAllocator::dump_l(String8& result, const char* what) const { size_t size = 0; int32_t i = 0; chunk_t const* cur = mList.head(); const size_t SIZE = 256; char buffer[SIZE]; snprintf(buffer, SIZE, " %s (%p, size=%u)\n", what, this, (unsigned int)mHeapSize); result.append(buffer); while (cur) { const char* errs[] = {"", "| link bogus NP", "| link bogus PN", "| link bogus NP+PN" }; int np = ((cur->next) && cur->next->prev != cur) ? 1 : 0; int pn = ((cur->prev) && cur->prev->next != cur) ? 2 : 0; snprintf(buffer, SIZE, " %3u: %08x | 0x%08X | 0x%08X | %s %s\n", i, int(cur), int(cur->start*kMemoryAlign), int(cur->size*kMemoryAlign), int(cur->free) ? "F" : "A", errs[np|pn]); result.append(buffer); if (!cur->free) size += cur->size*kMemoryAlign; i++; cur = cur->next; } snprintf(buffer, SIZE, " size allocated: %u (%u KB)\n", int(size), int(size/1024)); result.append(buffer); }
int main(int argc, char** argv) { LinkedList linkedList; linkedList.add(2); linkedList.add(5); linkedList.add(1); linkedList.add(6); linkedList.out(); linkedList.clear(); linkedList.out(); return 0; }
void Matrix::BFS(Point start, int rows, int cols, LinkedList<Point>& path) { if (matrix[start.getX()][start.getY()] == '#') { cout << "The position is invalid!\n"; return; } int dr[] = { 0, -1, 0, 1 }; int dc[] = { -1, 0, 1, 0 }; Queue<Point> queue; queue.Enqueue(start); matrix[start.getX()][start.getY()] = '?'; cout << "Starting from point: "; cout << "(" << start.getX() << ", " << start.getY() << ")" << " : " << endl; while (!queue.isEmpty()) { start = queue.Front(); queue.Dequeue(); for (int d = 0; d < 4; d++) { Point nextPos(start.getX() + dr[d], start.getY() + dc[d]); if (canPass(rows, cols, nextPos)) { path.Push_Back(nextPos); queue.Enqueue(nextPos); matrix[nextPos.getX()][nextPos.getY()] = '?'; } } } }
void LinkedListTest::listBackReference() { LinkedList list; Item* item = new Item; /* Insert -> list is backreferenced from the item */ list.insert(item); CORRADE_VERIFY(item->list() == &list); /* Cut -> list is not referenced */ list.cut(item); CORRADE_VERIFY(item->list() == nullptr); /* Destruct -> item removes itself from the list */ list.insert(item); CORRADE_VERIFY(!list.isEmpty()); delete item; CORRADE_VERIFY(list.isEmpty()); }
/******************************************************************************** * void oldLoop(): * Purpose: * some code I first used to test the class * called oldLoop() because it is older than the current main() * * Entry: * nothing * * Exit: * (verbosely states what it is doing) * - creates a list * - appends the numbers 9000-9009 to it * - creates a copy of the list with the assignment operator = * - attempts to insert the number 9020 after 9002 * (throws error if 9002 isn't in there for some reason) * - prints the contents of the first list with an iterator for loop * - prints the contents of the copy with another iterator based loop * - says if isEmpty() actually knows that the list is empty * - (implicitly) calls destructor on list, destroying all nodes * ********************************************************************************/ void oldLoop() { //create an empty list cout << "creating list" << endl; LinkedList<int> myList; //append the numbers 9000-9009 to it cout << "appending ints" << endl; for(int i=9000; i<9010; i++) myList.Append(i); //make a copy of it using operator= cout << "creating copy" << endl; LinkedList<int> listCopy; listCopy=myList; try { //insert the number 9020 after 9002 listCopy.InsertAfter(9002, 9020); } catch (Exception e) { cout << "Error: " << e << endl; } //print the list and its copy cout << "printing the contents" << endl; for( auto it = myList.Begin(); it.isValid(); ++it) cout << *it << endl; for( auto it = listCopy.Begin(); it.isValid(); ++it) cout << "copy: " << *it << endl; //check if the list is empty cout << "checking if list is empty" << endl; cout << "List is " << (myList.isEmpty() ? "" : "not ") << "empty.\n"; }
void pad_extra_digits(LinkedList num_1, LinkedList num_2) { int len_1 = num_1.get_length(); int len_2 = num_2.get_length(); int diff = len_1 - len_2; for (int i = 1; i <= diff; i++) { if (len_1 > len_2) { num_2.add_element_front(0); } else if (len_1 < len_2) { num_1.add_element_front(0); } } LinkedList res; int carry = add_list_front(num_1.head, num_2.head, &res); if (carry != 0) res.add_element_front(carry); res.display_list(); }
LinkedList<LinkedList<int> > sequence_break_up(LinkedList<int> const& linked_list) { LinkedList<LinkedList<int> > result; LinkedListIterator<int> next_iterator = linked_list.begin(); LinkedListIterator<int> iterat = next_iterator++; while(iterat) { LinkedList<int> storage; while(next_iterator && (*next_iterator > *iterat)) { storage.insertEnd(*iterat); iterat = next_iterator++; } storage.insertEnd(*iterat); iterat = next_iterator++; result.insertEnd(storage); } return result; }
int main() { to_daemon(); signal(SIGINT, signal_callback); // open log setlogmask(LOG_UPTO(LOG_NOTICE | LOG_INFO | LOG_ALERT)); openlog("cpusaver", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON); // default values int threshold = 7, percent = 5; end_type et = Suspend; LinkedList<specialend>* immunes = NULL; // forbidden list LinkedList<string>* forblist = new LinkedList<string>(); forblist->addLast(new string("compiz")); forblist->addLast(new string("kwin")); forblist->addLast(new string("plasma-desktop")); forblist->addLast(new string("nautilus")); forblist->addLast(new string("xfwm")); // configure parameters and start monitoring passwd* pw = getpwuid(getuid()); syslog(LOG_NOTICE, "Start ======================"); if (!cfgread::readConfig(pw->pw_dir, threshold, et, percent, immunes, forblist)) { syslog(LOG_ALERT, "Configuration file invalid; using default configuation."); cfgread::writeDefaultConfig(pw->pw_dir, threshold, et, percent, immunes, forblist); } pm = new ProcessManager(threshold, et, percent, immunes, forblist); // finishing and closing monitor bool status = pm->start(); delete pm; syslog(LOG_NOTICE, "Finish ====================="); closelog(); if (status == false) return EXIT_FAILURE; return 0; }
int main( int argc, char* argv[] ) { using namespace ds; ds::TextReader textReader("D:\\cpp_practise\\file_reader\\text.txt"); textReader(); LinkedList linkedList; //populating linkedList std::vector<std::string> strVec = textReader.strVec(); for (std::vector<std::string>::iterator strIt = strVec.begin(); strIt != strVec.end(); ++strIt) { linkedList.addNode(*strIt); } std::cout << "list size: " << linkedList.size() << std::endl; // now reversing the linked list Node* newHead = NULL; Node* curNode = linkedList.head(); while (curNode != NULL) { Node* nextNode = curNode->next(); curNode->setNext(newHead); newHead = curNode; curNode = nextNode; } linkedList.head(newHead); // now print the reverse lined list curNode = linkedList.head(); while (curNode) { std::string str = curNode->item(); std::cout << str << " "; curNode = curNode->next(); } return 0; }
int main() { LinkedList list; double input; // Store values in list for (int i = 1; i <= 10 ; i++) list.add(i * 2.5); // Print list cout << "These a the contents of the list:\n"; list.print(); cout << "Removing \"5.0\" from list.\n"; list.remove(5.0); cout << "These a the contents of the list:\n"; list.print(); cout << "Enter a value to remove from list: "; cin >> input; list.remove(input); cout << "These a the contents of the list:\n"; list.print(); return 0; }
int main() { //create an empty list LinkedList myList; int N = 5; for (int i = 0; i < N; ++i) { myList.append(i); myList.append(i); myList.append(i); } myList.insert(4, 5); myList.printLinkedList(); myList.removeByValue(4); myList.printLinkedList(); return 0; }
BOOL areSocketThreadsRunning() { LinkedList * l; socketDescriptor * sd; if (serverList) { for (l=serverList->first(); l->isNotLast(); l=l->next()) { sd = (struct socketDescriptor *) l->get(); if (sd->hThread) return TRUE; } } if (clientList) { for (l=clientList->first(); l->isNotLast(); l=l->next()) { sd = (struct socketDescriptor *) l->get(); if (sd->hThread) return TRUE; } } return FALSE; }
int main(){ LinkedList looplist; for(int i=0; i<20; i++){ looplist.append(i); // let the tail node point to a middle node } ListNode * tail = looplist.at(20); tail->next = looplist.at(10); ListNode * loopstart = loopBeginning(looplist); cout<<"Loop Beginning Node.data = "<<loopstart->data<<endl; LinkedList nonlooplist; for(int i=1; i<3; i++){ nonlooplist.append(i); } if(loopBeginning(nonlooplist) == NULL){ cout<<"It is a nonloop list"<<endl; } return 0; }
public int maxDepth(TreeNode root) { if(root == null) return 0; //必须要进行空指针判断,否则出现nullpointer异常 int max = 1; LinkedList<TreeNode> arr = new LinkedList<>(); root.val = 1; arr.addLast(root); while (arr.size() != 0){ TreeNode temp = arr.getFirst(); if (temp.left != null){ temp.left.val = temp.val + 1; arr.addLast(temp.left); if (temp.left.val > max) max = temp.left.val; } if (temp.right != null){ temp.right.val = temp.val + 1; arr.addLast(temp.right); if (temp.right.val > max) max = temp.right.val; } arr.removeFirst(); } return max; }
void testFind(ostream & os){ printSubheader("FIND",os); LinkedList<string> ll; ll.Insert("Muh!",NULL); ll.Insert("Buh!",NULL); ll.Insert("Juh!",NULL); ll.Insert("Buh!",NULL); LLNode<string>* node; node = ll.Find("Buh!",NULL); TESTM(node->GetPrevious() == NULL,"Expected: NULL\nActual: " + node->GetPrevious()->GetValue()); TESTM(node->GetNext()->GetValue() == "Juh!","Expected: Juh!\nActual: " + node->GetNext()->GetValue()); TESTM(node->GetValue() == "Buh!","Expected: Buh!\nActual: " + node->GetValue()); LLNode<string>* node2 = ll.Find("Buh!",ll.GetFirst()); if(node2 == NULL) TESTM(node2->GetPrevious()->GetValue() == "Juh!","Expected: Juh!\nActual: " + node2->GetPrevious()->GetValue()); TESTM(node2->GetNext()->GetValue() == "Muh!","Expected: Muh!\nActual: " + node2->GetNext()->GetValue()); TESTM(node2->GetValue() == "Buh!","Expected: Buh!\nActual: " + node2->GetValue()); }
int main() { LinkedList *ll = new LinkedList(); ll->Insert(15); ll->Insert(12); ll->Insert(13); ll->Insert(55); ll->Insert(55); ll->Insert(13); ll->Insert(12); ll->Insert(15); if (IsPalindrome(ll->GetHead())) { cout << "is palindrome!" << endl; } else { cout << "Not palindrome!" << endl; } }
int main() { LinkedList<int> list; list.addToFront(1); list.addToFront(2); list.addToFront(3); list.addToFront(4); LinkedList<int>::Iterator it = list.iterator(); while (it.hasNext()) { cout << it.next() << endl; } cout << endl; list.remove(3); it = list.iterator(); while (it.hasNext()) { cout << it.next() << endl; } cout << endl; return 0; }
int main(int argc, const char * argv[]) { LinkedList testList = *new LinkedList(); testList.insertBack(30); testList.insertBack(20); testList.insertInfront(10); testList.insertInfront(30); testList.printContents(); // std::cout << "Detecting Duplicates Without Buffer Test \n"; // testList.findDuplicatesWithoutBuffer(); // testList.printContents(); std::cout << "Detecting Duplicates With Buffer Test \n"; testList.findDuplicatesWithBuffer(); testList.printContents(); return 0; }
void ReadDataFile(){ cout << "Opening data file 'data_" << FileNumber << ".txt'..." << endl; string file = "data_" + FileNumber + ".txt"; DataFile.open(file.c_str()); if (!DataFile){ TerminateError("Unable to open data file."); } ListNode<ListNodeData> *node = NULL; //Find the last node to append the list, if the list is already with items. TheList.Rewind(); while (TheList.Current() != NULL){ node = TheList.Current(); TheList.Next(); } string text, dummy; int number; //Read data file into list while (!DataFile.eof()){ GetLine(DataFile, text); //GetLine gets rid of newline character. if (DataFile.eof()){ //EOF was reached before a number is read!? Means file is malformed. Ignoring final node. cout << "Unexpected end of file for data file. Finishing read." << endl; break; } DataFile >> number; getline(DataFile, dummy); //Use GetLine to clear the newline character. //The default behaviour of inserting new nodes to the list is by inserting it at the first node. //So we need a "workaround" to build the list as it was defined in the data file. cout << "Appending Node " << text << " " << number << endl; if (node == NULL){ node = TheList.InsertNewNode(ListNodeData(number, text)); //This is the first node. } else{ node = TheList.AppendNode(node, ListNodeData(number, text)); //Append additional node behind the first node } } DataFile.close(); }
socketDescriptor * allocateServerSocketDescriptor(socketDescriptor * p) { LinkedList * l; struct socketDescriptor * serverSd; char * host = (char *) malloc(strlen(p->host)+1); char * description = (char *) malloc(strlen(p->description)+1); for (l=serverList->first(); l->isNotLast(); l=l->next()) { serverSd = (struct socketDescriptor *) l->get(); if (serverSd->hThread==NULL) break; // socket descriptor is free for reuse } if (l->isLast()) { serverSd = (socketDescriptor *) malloc(sizeof(struct socketDescriptor)); l->add(serverSd); } serverSd->host = host; serverSd->description = description; copySocketDescriptor(serverSd, p); return serverSd; }
// The problem is find the kth to last element of a singly linked list // There are three versions of solutions to this problem: // 1. If the linked list size is known, jsut iterate though the list to find the (size-k)th element in the list // 2. A recursive version to find the kth of the last element // 3. A iterative version utilized the "runne" technqiue int main(int argc, char *argv[]){ LinkedList myList; int val,size, k, select; cout << "please insert the size of linked list" << endl; cin >> size; for(int i = 0;i < size ; i++){ cin >> val; myList.append(val); } cout << "Now the list is " << endl; myList.display(); cout << endl; cout << "which one you want to see?" << endl; cin >> k; cout << "which version? 1. iteration 2. recursive" << endl; cin >> select; if(select == 1){ ListNode *chosen = myList.kthlastIter(k); if(chosen) cout << "Now the value of node is " << chosen->val << endl; else cout << "k is out of the range" << endl; }else{ int m = 0; ListNode *chosen = myList.kthlastRecur(myList.currentHead(),m, k); if(chosen) cout << "Now the value of node is " << chosen->val << endl; else cout << "k is out of the range" << endl; } return 0; }
int main(int argc, char** argv) { using namespace std; void (*work)(Medium*); work = print; Medium *a = new Audio("Bryan Adams", 222); a->setTitel("Summer of 69"); a->setJahr(1993); Medium *b = new Bild("London"); b->setTitel("Abbey Road"); b->setJahr(1962); LinkedList<Medium*> liste; liste.append(b); liste.insert(a, 2); LinkedList<Medium*> liste2 = liste; cout << "Liste:" << endl; // liste.visit_all(work); liste.visit_all(print); liste.remove(2); cout << "Liste: " << endl; liste.visit_all(work); cout << "Liste2: " << endl; liste2.visit_all(work); return 0; }
int main(int argc, char** argv) { using namespace std; void (*work) (const char*); work = print; LinkedList liste; liste.append("Element 1"); liste.insert("Element 2", 2); LinkedList liste2 = liste; cout << "Liste:" << endl; liste.visit_all(*work); liste.remove(2); cout << "Liste: " << endl; liste.visit_all(*work); cout << "Liste2: " << endl; liste2.visit_all(*work); return 0; }
int main() { int option; LinkedList PortfolioList; StockAccount stock; BankAccount myAccount; bool flag1=false; bool flag2=false; bool already_in_list=false; //for transaction file string trans_type [60], trans_sym[60], trans_time[60]; double trans_price[60], trans_total[60]; int trans_num[60]; //for stocks file string company_name[60], date[60]; double price_per_share[60]; int account_index; int k=0, m=0; //for account information file string account_sym[60]; double account_price[60], account_total[60]; int account_num[60]; //for Bank Account double myAmount; //transaction type string type; stock.readStockFile(company_name,price_per_share,date); //read stock file stock.read_transaction_history(trans_type,trans_sym,trans_num, trans_price, trans_total,trans_time); //read transaction history stock.read_account_information(account_sym,account_num, account_price, account_total); //read account information double myBalance=PortfolioList.CopyToPortfolioList(PortfolioList,stock,account_sym,account_num, account_price, account_total); //copy account information to Portfolio List cout<<"Welcome to the Account Management System.\n\n"; while(1) { cout<<"Please select an account to access:"<<endl <<"1. Stock Portfolio Account"<<endl <<"2. Bank Account"<<endl <<"3. Exit"<<endl <<"Option: "; cin>>option; switch(option) { case 1: //Stock Management System cout<<"\n\nStock Portfolio Account"<<endl; while(1) { cout<<"Please select an option:"<<endl <<"1. Display the price for a stock symbol"<<endl <<"2. Display the current portfolio"<<endl <<"3. Buy shares"<<endl <<"4. Sell shares"<<endl <<"5. View transaction history"<<endl <<"6. Return to previous menu"<<endl; cin>>option; if(option==6) //return to previous menu break; switch(option) { case 1: stock.display_stock_price(company_name,price_per_share); //display stock price break; case 2: PortfolioList.~LinkedList(); //clear linked list stock.read_account_information(account_sym,account_num, account_price, account_total); //read account information myBalance=PortfolioList.CopyToPortfolioList(PortfolioList,stock,account_sym,account_num, account_price, account_total); //copy account information to LinkedList PortfolioList.SortLinkedList(); //sort the Linked List PortfolioList.printList(); //print the Linked List break; case 3: flag1=stock.buy_shares(company_name,price_per_share); //buy shares already_in_list=stock.alreadyInList(account_sym,account_index); //check to see if the stock is already in list if(flag1) //if transaction went through { type="Buy"; if(already_in_list) //if in list { stock.update_account_information(account_sym,account_num,account_price,account_total,account_index); //just update the list(no new entry) } else //if it's not in the list { stock.store_account_information(stock); //store the stock in account information } } stock.store_transaction(stock,type); //store tranaction in file break; case 4: flag2=stock.sell_shares(account_sym,account_price); //sell shares already_in_list=stock.alreadyInList(account_sym,account_index); //check to see if the stock is already in list if(flag2) //if transaction went through { type="Sell"; stock.update_sell_information(account_sym,account_num,account_price,account_total,account_index); //just update the list } stock.store_transaction(stock,type); //store tranaction in file break; case 5: stock.read_transaction_history(trans_type,trans_sym, trans_num, trans_price,trans_total, trans_time); cout<<"Event"<<setw(15)<<"Company Symbol"<<setw(9)<<"Number"<<setw(19)<<"Price per share"<<setw(15)<<"Total value"<<setw(11)<<"Time\n"; while(trans_sym[m]!="END") { cout<<trans_type[m]<<setw(7)<<trans_sym[m]<<setw(15)<<trans_num[m]<<setw(15)<<trans_price[m]<<setw(19)<<trans_total[m]<<setw(18)<<trans_time[m]<<endl; m++; } m=0; cout<<"\n"; break; default: cout<<"You entered an invalid number!"<<endl; break; } } break; case 2: //Bank Account cout<<"\n\nBank Account"<<endl; while(1) { cout<<"Please select an option:"<<endl <<"1. View account balance"<<endl <<"2. Deposit Money"<<endl <<"3. Withdraw Money"<<endl <<"4. Print out history"<<endl <<"5. Return to previous menu"<<endl; cin>>option; if(option==5) //return to previous menu break; switch(option) { case 1: myAccount.View_balance(); //View Balance break; case 2: cout<<"Please enter the amount: "<<endl; cin>>myAmount; myAccount.Deposit(myAmount); break; case 3: cout<<"Please enter the amount: "<<endl; cin>>myAmount; myAccount.Withdraw(myAmount); break; case 4: myAccount.Print_history(); break; default: cout<<"You entered an invalid number!"<<endl; break; } } break; case 3: //exit the program exit(0); default: break; } } return 0; }
void setup(){ for(int i = 0; i < 5; i++){ bunnyList.prepend(new Bunny()); } }
void Enemy::update(int* cameraX, int difficulty) { LinkedList* entities = getEntities(); Entity* curEntity = (Entity*)entities->getRoot(); cooldown++; while (curEntity != 0) { if (curEntity->getId() == PLAYER) { // look at player float dx = getDrawingSprite()->getPosition().x - *cameraX - curEntity->getDrawingSprite()->getPosition().x + *cameraX; float dy = getDrawingSprite()->getPosition().y - curEntity->getDrawingSprite()->getPosition().y; float length = sqrt(dx * dx + dy * dy); if ((difficulty == 1 && length < EASYENEMYRANGE) || (difficulty == 2 && length < MEDIUMENEMYRANGE) || (difficulty == 3 && length < HARDENEMYRANGE)) { aggroed = true; if ((difficulty == 1 && cooldown > EASYENEMYCOOLDOWN) || (difficulty == 2 && cooldown > MEDIUMENEMYCOOLDOWN) || (difficulty == 3 && cooldown > HARDENEMYCOOLDOWN)) { cooldown = 0; //shooot hiiiiiim float velx; float vely; if (difficulty == 1) { velx = dx / length * EASYDROPLETSPEED; vely = dy / length * EASYDROPLETSPEED; } else if (difficulty == 2) { velx = dx / length * MEDIUMDROPLETSPEED; vely = dy / length * MEDIUMDROPLETSPEED; } else { velx = dx / length * HARDDROPLETSPEED; vely = dy / length * HARDDROPLETSPEED; } Droplet* droplet = new Droplet(entities); droplet->setOwnerId(ENEMY); droplet->setX(getX()); droplet->setY(getY()); droplet->setVelx(-velx); droplet->setVely(-vely); droplet->getDrawingSprite()->setRotation(this->getDrawingSprite()->getRotation() + 180); entities->addNode(droplet); } } float radians = atan(dy / dx); float angle = radians * 180 / PI + 90.0f; if (curEntity->getDrawingSprite()->getPosition().x - *cameraX <= getX() - *cameraX) { angle += 180.0f; } getDrawingSprite()->setRotation(angle); if (aggroed) { float velx; float vely; if (difficulty == 1) { velx = dx / length * EASYENEMYSPEED; vely = dy / length * EASYENEMYSPEED; } else if (difficulty == 2) { velx = dx / length * MEDIUMENEMYSPEED; vely = dy / length * MEDIUMENEMYSPEED; } else { velx = dx / length * HARDENEMYSPEED; vely = dy / length * HARDENEMYSPEED; } move(-velx, -vely); } } curEntity = (Entity*)curEntity->getNext(); } }
void testLinkedList( LinkedList< T > &listObject, const string &typeName ) { cout << "Testing a LinkedList of " << typeName << " values\n"; instructions(); // display instructions int choice; // store user choice T value; // store input value do // perform user-selected actions { cout << "? "; cin >> choice; switch ( choice ) { case 1: // insert at beginning cout << "Enter " << typeName << ": "; cin >> value; listObject.insertAtFront( value ); listObject.print(); break; case 2: // insert at end cout << "Enter " << typeName << ": "; cin >> value; listObject.insertAtBack( value ); listObject.print(); break; case 3: // remove from beginning if ( listObject.removeFromFront( value ) ) cout << value << " removed from list\n"; listObject.print(); break; case 4: // remove from end if ( listObject.removeFromBack( value ) ) cout << value << " removed from list\n"; listObject.print(); break; case 6: cout << listObject.sum() << endl; break; case 7: {cout << "Enter element subscript : "; cin >> value; T something = listObject[value]; cout << "\nEntry is : " << something << endl; break;} case 8: listObject.reverse(); listObject.print(); break; } } while ( choice != 5 ); cout << "End list test\n\n"; }