Question: I need help with some guides and reference to this TO-DO question(Code in C++): Concatenate the right hand side media list of media
I need help with some guides and reference to this "TO-DO" question(Code in C++):
Concatenate the right hand side media list of media items to this list by repeatedly inserting at the bottom of this medialist. The input type is a container of media items accessible with iterators like all the other containers. The constructor above gives an example. Use MediaList::insert() to insert at the bottom.


MeditList.hpp
#pragma once // include guard
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "MediaItem.hpp"
class MediaList
{
// Insertion and Extraction Operators
friend std::ostream & operator
friend std::istream & operator>>( std::istream & stream, MediaList & mediaList );
// Relational Operators
friend bool operator==( const MediaList & lhs, const MediaList & rhs );
friend bool operator
public:
// Types and Exceptions
enum class Position {TOP, BOTTOM};
struct InvalidInternalState_Ex : std::domain_error { using domain_error::domain_error; }; // Thrown if internal data structures become inconsistent with each other
struct CapacityExceeded_Ex : std::length_error { using length_error::length_error; }; // Thrown if more items are inserted than will fit
struct InvalidOffset_Ex : std::logic_error { using logic_error ::logic_error; }; // Thrown of inserting beyond current size
// Constructors, destructor, and assignment operators
MediaList(); // construct an empty media list
MediaList( const MediaList & other ); // construct a media list as a copy of another media list
MediaList( MediaList && other ); // construct a media list by taking the contents of another media list
MediaList & operator=( MediaList rhs ); // intentionally passed by value and not const ref
MediaList & operator=( MediaList && rhs );
MediaList ( const std::initializer_list
MediaList & operator+=( const std::initializer_list
MediaList & operator+=( const MediaList & rhs ); // concatenates the rhs list to the end of this list
~MediaList();
// Queries
std::size_t size() const;
std::size_t find( const MediaItem & item ) const; // returns the (zero-based) offset from top of list
// returns the (zero-based) position of the item, size() if item not found
// Mutators
void insert( const MediaItem & item, Position position = Position::TOP ); // add the media item to the top (beginning) of the media list
void insert( const MediaItem & item, std::size_t offsetFromTop ); // inserts before the existing item currently at that offset
void remove( const MediaItem & item ); // no change occurs if item not found
void remove( std::size_t offsetFromTop ); // no change occurs if (zero-based) offsetFromTop >= size()
void moveToTop( const MediaItem & item );
void swap( MediaList & rhs ) noexcept; // exchange one media list with another
private:
// Helper functions
bool containersAreConsistant() const;
std::size_t media_sl_list_size() const; // std::forward_list doesn't maintain size, so calculate it on demand
// Instance Attributes
std::size_t _media_array_size = 0; // std::array's size is constant so manage that attributes ourself
std::array
std::vector
std::list
std::forward_list
};
// Relational Operators
bool operator==( const MediaList & lhs, const MediaList & rhs );
bool operator!=( const MediaList & lhs, const MediaList & rhs );
bool operator
bool operator
bool operator> ( const MediaList & lhs, const MediaList & rhs );
bool operator>=( const MediaList & lhs, const MediaList & rhs );
MediaList::Medialist( const std::initializer_list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
