Question: You will implement a sorted set (sorted_set.h) based on our linked_list class. The sorted set will be based on a singly linked list with a

 You will implement a sorted set (sorted_set.h) based on our linked_list

You will implement a sorted set (sorted_set.h) based on our linked_list class. The sorted set will be based on a singly linked list with a head which points to the next node. The nodes do not point to the previous Sorted Set operations: a. Rule of five b. NOTE - the constructor should take a Boolean optional (default value) argument to indicate if the order is natural (true) or reverse (false). The default value of the argument should be true. I. Natural order is: 1, 2, 3, 4, 5 ii. Reverse order is: 5, 4, 3, 2, 1 c. add (Boolean) adds an element to the set. This is the only way the set can be mutated. You need two copies of this method. One to add a reference and one to move an r-value. The add method should add the element to the correct location in the set. Remember, the sorted set keeps the elements in order. Duplicate items are rejected. The function should return true if the value is inserted, otherwise false. I. NOTE: C++ uses strict-weak ordering so when you find the location you can only use the operator! Keep that in mind. d. contains (Boolean) returns true if the item is in the set, otherwise false. e. remove (void) removes the given element. Be very careful here. Be mindful of how deleting elements could impact your iterator. f. size (size_t) return the number of elements in the set. 8. empty (Boolean) return true if the list is empty, otherwise false. h. clear (void) - clears all the elements from the set. I. stream insertion operator - display the values in the set from head to tail. i print_lot (void)- This method will take two arguments a ostream variable with a default value of cout and an vector of integers. The method will print to the given ostream the elements in the set that are in the positions specified by the vector. For instance, if the vector contains = 1, 3, 4, 6, the elements in positions 1, 3, 4, and 6 in the set are printed. If any of the specified positions are invalid then throw an out_of_range exception. k. iterators - const_iterator only (you can only mutate the set with the add method). The iterator will not have a decrement operation because it is a one-way set. Write a main method which shows all operations of your set working as expected. Include a foreach loop so you can show the iterators work as expected. Make sure to set the assignment operations as well. Test EVERY part of the set and use different data types to make sure it works. Make sure your natural order and reverse order work as expected. You will implement a sorted set (sorted_set.h) based on our linked_list class. The sorted set will be based on a singly linked list with a head which points to the next node. The nodes do not point to the previous Sorted Set operations: a. Rule of five b. NOTE - the constructor should take a Boolean optional (default value) argument to indicate if the order is natural (true) or reverse (false). The default value of the argument should be true. I. Natural order is: 1, 2, 3, 4, 5 ii. Reverse order is: 5, 4, 3, 2, 1 c. add (Boolean) adds an element to the set. This is the only way the set can be mutated. You need two copies of this method. One to add a reference and one to move an r-value. The add method should add the element to the correct location in the set. Remember, the sorted set keeps the elements in order. Duplicate items are rejected. The function should return true if the value is inserted, otherwise false. I. NOTE: C++ uses strict-weak ordering so when you find the location you can only use the operator! Keep that in mind. d. contains (Boolean) returns true if the item is in the set, otherwise false. e. remove (void) removes the given element. Be very careful here. Be mindful of how deleting elements could impact your iterator. f. size (size_t) return the number of elements in the set. 8. empty (Boolean) return true if the list is empty, otherwise false. h. clear (void) - clears all the elements from the set. I. stream insertion operator - display the values in the set from head to tail. i print_lot (void)- This method will take two arguments a ostream variable with a default value of cout and an vector of integers. The method will print to the given ostream the elements in the set that are in the positions specified by the vector. For instance, if the vector contains = 1, 3, 4, 6, the elements in positions 1, 3, 4, and 6 in the set are printed. If any of the specified positions are invalid then throw an out_of_range exception. k. iterators - const_iterator only (you can only mutate the set with the add method). The iterator will not have a decrement operation because it is a one-way set. Write a main method which shows all operations of your set working as expected. Include a foreach loop so you can show the iterators work as expected. Make sure to set the assignment operations as well. Test EVERY part of the set and use different data types to make sure it works. Make sure your natural order and reverse order work as expected

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!