Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MY QUESTION IS HOW DO I START IMPLEMENTING THE STRINGSET UNION METHOD IN THE CPP FILE? THANKS IN ADVANCE :D Methods String Set() - constructor

image text in transcribedimage text in transcribed

MY QUESTION IS HOW DO I START IMPLEMENTING THE STRINGSET UNION METHOD IN THE CPP FILE? THANKS IN ADVANCE :D

Methods String Set() - constructor that creates an array of strings of size 2 in dynamic memory, sets maximum size to 2, and current size to 0 StringSet(const StringSet &)- copy constructor that creates a deep copy of its parameter StringSet() - destructor that frees dynamic memory associated with the object's string (array) pointer String Set & operator= (const StringSet &)- overloaded assignment operator that creates a deep copy of its parameter, assigns it to the calling object, deallocates any no longer required dynamic memory associated with the calling object; this method should check for self assignment as discussed in class bool insert(string) - returns false without inserting value if a string matching the parameter is already in the array, otherwise: inserts the string parameter at the next available index; if the underlying array is full, doubles the maximum size attribute, creates an array of twice the size of the current array, copies the contents of the old array to the new array, frees memory associated with the old array, and assigns new array's address to object's array pointer, then inserts parameter; increments current size and returns true bool remove(string) - returns false if a string matching the parameter is not in the array, otherwise: replaces matching string with the last string in the array (if there is one); decrements current size and returns true int find(string) const - if a string matching the parameter is in the array returns the index of that string, otherwise returns -1 int size() const - returns the current size (the number of strings in the array) String Set unions(const StringSet &) const -returns a StringSet object that contains the union of the calling object and the parameter (if the result is the empty set the returned String Set object's current size should equal zero); in case you were wondering, this method is called unions because union is a reserved word StringSet intersection(const StringSet &) const - returns a StringSet object that contains the intersection of the calling object and the parameter . String Set difference(const String Set &) const -returns a String Set object that contains the set difference of the calling object and the parameter Methods String Set() - constructor that creates an array of strings of size 2 in dynamic memory, sets maximum size to 2, and current size to 0 StringSet(const StringSet &)- copy constructor that creates a deep copy of its parameter StringSet() - destructor that frees dynamic memory associated with the object's string (array) pointer String Set & operator= (const StringSet &)- overloaded assignment operator that creates a deep copy of its parameter, assigns it to the calling object, deallocates any no longer required dynamic memory associated with the calling object; this method should check for self assignment as discussed in class bool insert(string) - returns false without inserting value if a string matching the parameter is already in the array, otherwise: inserts the string parameter at the next available index; if the underlying array is full, doubles the maximum size attribute, creates an array of twice the size of the current array, copies the contents of the old array to the new array, frees memory associated with the old array, and assigns new array's address to object's array pointer, then inserts parameter; increments current size and returns true bool remove(string) - returns false if a string matching the parameter is not in the array, otherwise: replaces matching string with the last string in the array (if there is one); decrements current size and returns true int find(string) const - if a string matching the parameter is in the array returns the index of that string, otherwise returns -1 int size() const - returns the current size (the number of strings in the array) String Set unions(const StringSet &) const -returns a StringSet object that contains the union of the calling object and the parameter (if the result is the empty set the returned String Set object's current size should equal zero); in case you were wondering, this method is called unions because union is a reserved word StringSet intersection(const StringSet &) const - returns a StringSet object that contains the intersection of the calling object and the parameter . String Set difference(const String Set &) const -returns a String Set object that contains the set difference of the calling object and the parameter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Neo4j Data Modeling

Authors: Steve Hoberman ,David Fauth

1st Edition

1634621913, 978-1634621915

Students also viewed these Databases questions

Question

friendliness and sincerity;

Answered: 1 week ago