Implement in C a vector data structure in a generic way that can be used with any type of data. For reference, you can be guided by the operation of the vector class that is part of the STL (Links to...

A c generic linked list.


Implement in C a vector data structure in a generic way that can be used with any type of data. For reference, you can be guided by the operation of the vector class that is part of the STL (Links to an external site.). To traverse the vector to implement an iterator (iterator) that must have at least the necessary functions You should at least implement the following functions: vector () -> Create an empty vector vector (size_type n) -> Create a vector with n elements vector (size_type n, const T & t) -> Create a vector with n copies of t iterator insert (iterator pos, const T & x) -> Insert element x at position pos void insert (iterator pos, size_type n, const T & x) -> insert n copies of x at position pos void push_back (const T &) -> Insert an element at the end void pop_back () -> Remove the last element reference front () -> Returns a reference to the first element reference back () -> Returns a reference to the last element iterator erase (iterator pos) -> Delete the element that is in position pos iterator erase (iterator first, iterator last) -> Delete the elements between the first and last positions void clear () -> Remove all elements bool empty () const -> Returns true if the vector is empty, false otherwise iterator begin () -> Returns an iterator to the first element iterator end () -> Returns an iterator to the last element iterator next () -> Returns an iterator to the next element Important: Remember that there are no classes or object-oriented programming in C, so you must program everything in C using generic pointer, pointer arithmetic, and function pointers. Part 2 Write a C program that demonstrates the use of all the functions of the generic vector and the generic iterator with three different data types: A vector of integers A character vector A vector of a structure like the following: struct Book { char * title; int pages; } Add any other functions that you consider necessary.
Sep 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here