C++ DoubleLinkedList
For this assignment, create a class that represents a double linked list (forward and backward navigation), called DoubleLinkedList, of ints, that maintains a list in sorted order. The class should have the following operations:
DoubleLinkedList() : Appropriately initializes the object.
void insert(int value) : Inserts the value into the linked list, maintaining the sorted order.
void merge(DoubleLinkedList absorbedList) : Absorbs the provided list into the current list, maintaining sorted order. The absorbed list will be empty at the end of this operation.
void remove(int value) : removes an instance of the value provided from the list if it exists. If the value doesn't exist, the remove request takes no action. If the value is in the list more than once, only one instance needs to be removed.
const int& operator[](int index) const : Returns the value of the node in position index in the list. If the index is invalid, the operation throws an exception of type IndexOutOfBoundsException. You may declare the exception class in the header file for DoubleLinkedList. Note: Overloading [] in this way provides read, but not write, access to the array in a natural way.
int getCount() const : returns the number of elements in the list
void display(int reverse = false) const : this operation displays the linked list in forward order if reverse is false and reverse order if reverse is true.
Your solution will be evaluated on the correctness of the header and implementation file. You are encouraged to also submit your main.cpp which should exemplify how you went about testing your class to ensure correctness.
You must build the class manually (do not use templates in your solution) and you must use any global data.
源码传送门
传送门:https://pan.baidu.com/s/1JJs9vbZahUCB6cQvXLgAVg?pwd=1111
标签:int,list,value,order,DoubleLinkedList,C++,class From: https://www.cnblogs.com/codewriter/p/16841669.html