Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * [SList.cpp]
- * Sorted list example.
- *
- * compiler:
- * TDM-GCC 4.9.2 64-bit
- *
- * compile with:
- * g++ -m32 -static-libgcc -o slist SList.cpp SortedList.cpp
- */
- #include "SortedList.h"
- int main(void)
- {
- /**
- * Sorted List OBJECT CREATION:
- *
- * A pointer is used for pointers are very effective in reducing pushing and popping on the stack,
- * among other things.
- */
- SortedList *SList = new SortedList();
- /**
- * Sorted List ITEM INSERTION (In Random Order):
- */
- SList->InsertItem(2.5);
- SList->InsertItem(1.5);
- SList->InsertItem(1);
- SList->InsertItem(1.4);
- SList->InsertItem(1.5);
- /**
- * Sorted List ITEM OUTPUT:
- */
- SList->Print();
- std::cout << std::endl;
- /**
- * Sorted List ITEM DELETION:
- *
- * NOTE:
- * Without the decrement of the index value, inside the nested loop, in the SortedList::DeleteItem
- * method, only the first occurrence of the following supplied value would be deleted.
- */
- SList->DeleteItem(1.5);
- /**
- * Sorted List ITEM OUTPUT:
- */
- SList->Print();
- std::cout << std::endl;
- /**
- * Sorted List ITEM INSERTION:
- */
- SList->InsertItem(2.5);
- /**
- * Sorted List ITEM OUTPUT:
- */
- SList->Print();
- std::cout << std::endl;
- /**
- * Sorted List ITEM DELETION:
- *
- * NOTE:
- * Without the decrement of the index value, inside the nested loop, in the SortedList::DeleteItem
- * method, only the first occurrence of the following supplied value would be deleted.
- */
- SList->DeleteItem(2.5);
- /**
- * Sorted List ITEM OUTPUT:
- */
- SList->Print();
- std::cout << std::endl;
- /**
- * Another fundamental benefit of using pointers in C++, is the program's ability to clean them
- * out of memory when it is finished using them.
- */
- delete SList;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment