Phr0zen_Penguin

SLList.cpp - VTC C++ Data Structures Sorted Linked List Eg.

Apr 19th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. /**
  2.  * [SLList.cpp]
  3.  * Sorted linked list example.
  4.  *
  5.  * compile with:
  6.  * g++ -m32 -static-libgcc -o sllist SLList.cpp SortedLinkedList.cpp
  7.  */
  8.  
  9. #include "SortedLinkedList.h"
  10.  
  11. int main(void)
  12. {
  13.     /**
  14.      * Sorted Linked List OBJECT CREATION:
  15.      */
  16.     SortedLinkedList    *mySortedLinkedList = new SortedLinkedList();
  17.  
  18.  
  19.     /**
  20.      * Sorted Linked List ITEM ADDITION:
  21.      */
  22.     mySortedLinkedList->InsertItem(7);
  23.     mySortedLinkedList->InsertItem(2);
  24.     mySortedLinkedList->InsertItem(6);
  25.  
  26.  
  27.     /**
  28.      * Sorted Linked List OUTPUT:
  29.      */
  30.     std::cout << "ITEMS: " << std::endl;
  31.     mySortedLinkedList->Print();
  32.     std::cout << std::endl << "LENGTH: " << mySortedLinkedList->LengthIs() << std::endl << std::endl << std::endl;
  33.  
  34.  
  35.     /**
  36.      * Sorted Linked List ITEM ADDITION:
  37.      */
  38.     mySortedLinkedList->InsertItem(1.5);
  39.     mySortedLinkedList->InsertItem(2.6);
  40.     mySortedLinkedList->InsertItem(1.5);
  41.  
  42.  
  43.     /**
  44.      * Sorted Linked List OUTPUT:
  45.      */
  46.     std::cout << "ITEMS: " << std::endl;
  47.     mySortedLinkedList->Print();
  48.     std::cout << std::endl << "LENGTH: " << mySortedLinkedList->LengthIs() << std::endl << std::endl << std::endl;
  49.  
  50.  
  51.     /**
  52.      * Sorted Linked List ITEM DELETION:
  53.      */
  54.     mySortedLinkedList->DeleteItem(1.5);
  55.  
  56.  
  57.     /**
  58.      * Sorted Linked List OUTPUT:
  59.      */
  60.     std::cout << "ITEMS: " << std::endl;
  61.     mySortedLinkedList->Print();
  62.     std::cout << std::endl << "LENGTH: " << mySortedLinkedList->LengthIs() << std::endl << std::endl << std::endl;
  63.  
  64.  
  65.     /**
  66.      * Sorted Linked List ITEM ADDITION:
  67.      */
  68.     mySortedLinkedList->InsertItem(2.6);
  69.  
  70.  
  71.     /**
  72.      * Sorted Linked List ITEM DELETION:
  73.      */
  74.     mySortedLinkedList->DeleteItem(2.6);
  75.  
  76.  
  77.     /**
  78.      * Sorted Linked List OUTPUT:
  79.      */
  80.     std::cout << "ITEMS: " << std::endl;
  81.     mySortedLinkedList->Print();
  82.     std::cout << std::endl << "LENGTH: " << mySortedLinkedList->LengthIs() << std::endl;
  83.  
  84.  
  85.     /**
  86.      * Sorted Linked List OBJECT DELETION:
  87.      */
  88.     delete mySortedLinkedList;
  89.  
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment