[Solved] CSE 241/505- HW6- Templates and STL

$25

File Name: CSE_241/505-_HW6-_Templates_and_STL.zip
File Size: 329.7 KB

SKU: [Solved] CSE 241/505- HW6- Templates and STL Category: Tag:
5/5 - (1 vote)

CSE 241/505Object Oriented ProgrammingFall 2018Homework # 6Templates and STLDue date Dec 30th 2018As we discussed in the lectures, Java has a very structured Collections library. We can develop asimilar library for C++ that use STL classes underneath. We will implement some the interfaces(abstract classes with pure virtual functions only), some concrete classes, and some of the helperclasses such as iterators.

The above figure shows a simplified version of the Collections. We will write correspondingtemplated classes for Collection, Set, List, Queue, which are all abstract classes with all pure virtualfunctions with no data members. HashSet, ArrayList, and LinkedList are concrete classes. Note thatLinkedList uses multiple inheritance. Following table defines the functions for each classClass Name Public Function Name DefinitionCollection This is a templated class with two template parameters like the std::stack class of STL. Thefirst parameter is the template type E and the second parameter is the STL container that willdo all the work for us.iterator()Returns an iterator over the collectionadd(E e)Ensures that this collection contains the specified elementaddAll(Collection c)Adds all of the elements in the specified collection to thiscollectionclear()Removes all of the elements from this collectioncontains(E e)Returns true if this collection contains the specified element.containsAll(Collection c)Returns true if this collection contains all of the elements in thespecified collection.isEmpty()Returns true if this collection contains no elements.remove(E e) Removes a single instance of the specified element from thiscollection, if it is presentremoveAll(Collection c)Removes all of this collections elements that are also contained in the specified collectionretainAll(Collection c)Retains only the elements in this collection that are contained in the specified collectionsize()Returns the number of elements in this collection.SetA collection that contains no duplicate elements. There is no order for this collection. In other words, you dont have to keep the insertion order of the elements.ListAn ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted.QueueQueues order elements in a FIFO (first-in-first-out) manner. There is no random access with this Collection. Some functions throw exceptions.add(E e)Inserts the specified element into this queueelement()Retrieves, but does not remove, the head of this queue.offer(E e)Inserts the specified element into this queuepoll()Retrieves and removes the head of this queue, or throws if this queue is empty.HashSetImplements Set functionsArrayListImplements List functionsLinkedListImplements both List and Queue functions. Your class does not have to have a linked list to implement these.IteratorhasNext()Returns true if the iteration has more elements.next()Returns the next element in the iteration and advances the iterator.remove()Removes from the underlying collection the last element returned by this iteratorYour C++ Collections hierarchy should use only STL containers in the concrete classes to implement all the functions. Second parameter of the Collection template can be any of std::vector (default container), std::list, and std::set.You will test each function of each concrete class with template parameters of int and string. You will also use the three possible containers with all combinations.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE 241/505- HW6- Templates and STL
$25