int main(){ DLL list; int n,m,data,before; Node *contoh; /* cin >> n; for(int i=0;i<n;i++){ cin >> data; list.push_back(data); } cin >> m; for(int i=0;i<m;i++){ cin >> before; list.push_before(data); } */ list.push_back(10); list.push_back(30); list.push_back(50); contoh = list.find(10); cout << contoh->info << endl; //list.push_before(10); list.print(); return 0; }
int main() { cout << "************P-6.1*******************\n"; ArrayVector<int> A(3); cout << A << endl; A.insertFront(20); A.debug(); cout << A << endl; A.insertFront(10); A.debug(); cout << A << endl; A.insertFront(1); A.debug(); cout << A << endl; A.insertFront(-10); A.debug(); cout << A << endl; A.insertFront(-20); A.debug(); cout << A << endl; A.insertFront(-30); A.debug(); cout << A << endl; A.insertFront(-40); A.debug(); cout << A << endl; A.insertBack(30); A.debug(); cout << A << endl; A.insertFront(-50); A.debug(); cout << A << endl; cout << "************P-6.2*******************\n"; DLL <int> B; cout << B << endl; B.insertAfter(B.head, 1); cout << B << endl; try{ B.insertAfter(B.head, 2); } catch (RuntimeException e) { cout << e.getMessage() << endl; } cout << B << endl; B[1] = 3; cout << B << endl; cout << B[1] << endl; cout << B.at(1) << endl; B.at(1) = 2; cout << B << endl; }
int main(){ int n; string warna; int tinggi; DLL list; cin >> n; while(n--){ cin >> warna >> tinggi; list.push(warna,tinggi); } list.print(); return 0; }
void main() { DLL l; int data,pos,ch=0; while(ch!=6) { cout<<"\n\n---DLL ops---\n"; cout<<"\n1.display"; cout<<"\n2.Insert"; cout<<"\n3.Delete"; cout<<"\n4.Insert sort"; cout<<"\n5.Display Reverse"; cout<<"\n6.Exit"; cout<<"Enter the choice"; cin>>ch; switch(ch) { case 1: cout<<l; break; case 2: cout<<"\n\nEnter the data"; cin>>data; cout<<"\nEnter the position"; cin>>pos; l.InsertPos(data,pos); break; case 3: cout<<"\nEnter the position"; cin>>pos; l.DeletePos(pos); break; case 4: cout<<"\nEnter the data\n"; cin>>data; l.InsertSorted(data); break; case 5: l.dis_rev(); break; } } }
void algot::HashTable::resizeTo(unsigned int newSize){ algot::DLL<std::string>* newTable = new algot::DLL<std::string>[newSize]; unsigned int newUsedCells = 0; for(unsigned int i = 0; i < tableSize; i++){ algot::DLL<std::string>* list = table + i; const algot::DLLNode<std::string>* first = list->getHead()->next_; for(auto it = first; it != list->getTail(); it = it->next_){ std::string newString = std::string(it->value_); unsigned int newIndex = useHash(newString, newSize); DLL<std::string>* newList = newTable + newIndex; if(newList->isEmpty()){ newUsedCells++; } newList->add(newString); } } this->usedCells = newUsedCells; this->tableSize = newSize; delete[] table; table = newTable; }
int main(int argc, const char * argv[]) { DLL dll = DLL(); Node *head = dll.getRoot(); dll.add(&head, 7); dll.add(&head, 6); dll.add(&head, 5); dll.add(&head, 4); dll.add(&head, 3); dll.add(&head, 2); dll.add(&head, 1); dll.printList(head); return 0; }
void main() { int pos,ch; Emp e; DLL l; while(ch!=4) { cout<<"\n\n---DLL---\n"; cout<<"\n1.display"; cout<<"\n2.Insert Position"; cout<<"\n"; cout<<"\n4.exit"; cout<<"\nEnter the choice:"; cin>>ch; switch(ch) { case 1: l.display(); break; case 2: cout<<"\nEnter the info"; cin>>e; cout<<"\nEnter the position:"; cin>>pos; l.InsertPos(e,pos); break; case 3: cout<<"\nEnter the position:"; cin>>pos; l.DeletePos(pos); break; } } }
int main(){ DLL list; list.push_back(10); list.push_front(20); list.push_front(30); list.push_after(10,50); list.del(20); list.print(); return 0; }
int main(){ DLL l; int i; for(i=0;i<10;i++){ l.Insert(i); } printf("Going to head\n"); l.goHead(); l.Delete(); printf("Going to tail\n"); l.goTail(); l.Delete(); for(i=0;i<3;i++)l.goPrev(); l.Delete(); return 0; }
int main() { DLL <int> l; l.insertBack(3); l.insertFront(2); l.insertBack(4); l.insertFront(1); l.insertBack(5); l.print(); l.insertBack(1); l.print(); l.insertFront(1); DLL <int> v; v.insertBack(1); v.print(); v.insertBack(1); v.print(); v.insertFront(1); v.insertBack(2); v.insertFront(3); v.print(); }