Created
October 25, 2020 05:37
-
-
Save GiangHoGoVap/716f7615122be152c503a03def070713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main(){ | |
| FragmentLinkedList<int> list; | |
| cout << "size of list1: " << list.size() << endl; | |
| FragmentLinkedList<int> fList = FragmentLinkedList<int>(); | |
| for(int i = 0; i < 20 ; i++) | |
| fList.add(i * i); | |
| for(FragmentLinkedList<int>::Iterator it = fList.begin(); it != fList.begin(1); it++) | |
| { | |
| cout << *it << " "; | |
| } | |
| cout << endl; | |
| cout << "size of list2: " << fList.size()<<endl; | |
| for(int i = 0; i < 20;i++) | |
| { | |
| fList.removeAt(fList.size()-1) ; | |
| } | |
| cout << "size of list2 after removeAt: " << fList.size() << endl; | |
| fList.add(0,30); | |
| //fList.add(2,32); | |
| fList.add(1,33); | |
| fList.add(35); | |
| fList.add(36); | |
| fList.add(37); | |
| fList.add(38); | |
| fList.add(5,40); | |
| fList.add(0,41); | |
| //fList.removeItem(36); | |
| cout << "toString: " << fList.toString() << endl; | |
| cout << "contain 25?: " << fList.contains(25) << endl; | |
| cout << "contain 38?: " << fList.contains(38) << endl; | |
| cout << "index of 38: " << fList.indexOf(38) << endl; | |
| cout << "index of 45: " << fList.indexOf(45) << endl; | |
| fList.set(4,25); | |
| cout << "---------------------\n"; | |
| cout << "toString: " << fList.toString() << endl; | |
| cout << "get 4th element: " << fList.get(4) << endl; | |
| cout << "contain 25?: " << fList.contains(25) << endl; | |
| cout << "size of list one more time: " << fList.size()<<endl; | |
| cout << "remove item = 30: " << fList.removeItem(30)<<endl; | |
| fList.add(2,38); | |
| cout << "remove item = 38: " << fList.removeItem(38) << endl; | |
| cout << "remove item = 37: " << fList.removeItem(37) << endl; | |
| //cout << fList.removeItem(36) << endl << endl; | |
| cout << "remove item = 35: " << fList.removeItem(35) << endl; | |
| cout << "size of the list one one more time: " << fList.size() << endl; | |
| fList.add(90); | |
| fList.add(6,91); | |
| //FragmentLinkedList<int>::Iterator it1 = fList.begin(); | |
| // | |
| //it1.remove(); | |
| FragmentLinkedList<int>:: Iterator it1 = fList.end(0); | |
| it1.set(24); | |
| cout << "toString: " << fList.toString() << endl; | |
| for(FragmentLinkedList<int>::Iterator it = fList.begin(1); it != fList.end(); it++) | |
| { | |
| cout << *it << " "; | |
| //it.remove(); | |
| } | |
| cout << endl; | |
| //cout << fList.removeItem(41); | |
| FragmentLinkedList<int>:: Iterator it2 = fList.begin(); | |
| for(int i = 0; i < 4; i++) | |
| it2++; | |
| it2.remove(); | |
| for(; it2 != fList.end(); it2++) | |
| { | |
| cout << *it2 << " "; | |
| } | |
| return 0; | |
| } |
GiangHoGoVap
commented
Oct 27, 2020
Author

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment