Question: Need help in iterator function and code the iterator functions and methods in C++. Need help coding not algorithm pls... Need coding for the function

Need help in iterator function and code the iterator functions and methods in C++. Need help coding not algorithm pls... Need coding for the function calls in Bold.  #ifndef PERSISTENT_VECTOR_H #define PERSISTENT_VECTOR_H #include #include #include #include #include template class persistent_vector { private: class node { public: virtual ~node() {} virtual void print_details() const = 0; virtual const T& index(size_t height, size_t index) const = 0; //virtual std::shared_ptr replace(size_t height, size_t index, const T& value) const = 0; virtual std::shared_ptr push_back(size_t height, size_t index, const T& value) const = 0; }; typedef std::shared_ptr node_ptr; class leaf_node : public node { public: leaf_node(const T& first ): m_values { first } { } leaf_node(const T& first, const T& second ) : m_values { first, second} { } virtual ~leaf_node() { } void print_details() const { std::cout print_details(); if ( m_right ) m_right->print_details(); } const T& index(size_t height, size_t index) const { return (go_right(index,height)?m_right:m_left)->index(height-1,index); } /ode_ptr replace(size_t height, size_t index, const T& value) const { // //} node_ptr push_back(size_t height, size_t index, const T& value) const { if ( go_right(index,height) ) return std::make_shared( m_left, m_right?m_right->push_back(height-1,index,value):make_chain(height-1,value) ); return std::make_shared( m_left->push_back(height-1,index,value), m_right); } private: const node_ptr m_left; const node_ptr m_right; }; template std::vector make_pairs(const vector_type& v){ std::vector nodes; for(size_t i=0; i 1)?floor(log2(m_size-1)):0; } persistent_vector( node_ptr head, size_t size) : m_head(head), m_size(size), m_height(compute_height(size)) { } public:  /* class iterator { public: iterator(const persistent_vector pv, bool end=false): m_pv(pv), m_index(end?pv.m_size:0) {} // // This operator is used to get the value // that the iterator is currently pointing at // const T& operator *() { } // // This operator is used to move the iterator // to the next value in the container // iterator& operator ++()  persistent_vector(): m_size(0),m_height(0) {} persistent_vector(const persistent_vector& other) : m_head(other.m_head), m_size(other.m_size), m_height(other.m_height) {} persistent_vector(const std::vector& v) : m_head(build_tree(make_pairs(v))), m_size(v.size()), m_height(compute_height(m_size)) {} const persistent_vector& operator=(const persistent_vector& other) { m_height = other.m_height; m_size = other.m_size; m_head = other.m_head; return *this; } const T& at(size_t index) const { if ( index >= m_size) throw std::out_of_range("out-of-range"); return m_head->index(m_height,index); } const T& operator[](size_t index) const { return at(index); } persistent_vector push_back(const T& value) const { if(m_size==0) return persistent_vector(std::make_shared(value),1); if( full_tree(m_size,m_height) ) return persistent_vector( std::make_shared( m_head, make_chain(m_height,value)),m_size+1); return persistent_vector(m_head->push_back(m_height,m_size,value),m_size+1); } persistent_vector replace(size_t index, const T& value) const { if ( index >= m_size) throw std::out_of_range("out-of-range"); // } void print_details() const { std::cout print_details(); } size_t size() const { return m_size; } private: node_ptr m_head; size_t m_size; size_t m_height; }; #endif // defined PERSISTENT_VECTOR_H 

Need help in iterator function and code the iterator functions and methods

Add an iterator capability to the persistent vector Basically, the code int main std vector int v 10, 11, 12, 13, 15, 16, 17, 18 persistent vecto int persistent vecto int Riterator it while it vendoD std:: cout return 0 should produce 10 13 15 17 18

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!