Question: stantiate the DSA _ Lab 2 class to use these methods. Let me know if you need further assistance! You Overview The std::vector class is
stantiate the DSALab class to use these methods. Let me know if you need further assistance!
You
Overview The std::vector class is a templated sequence container class that stores data contiguously through the internal use of a dynamic array This enables them to be used in place of arrays, and provide additional flexibility, without having to completely refactor the code. This lab focuses on using several of the key methods provided by the class. While the last lab focused on writing your own version of the class, it is just as important to be able to use the builtin versions provided by the language. Things to Review Calling class methods Binary file IO New Topics File headers metadata Iterators Data Members mValues The main vector that will be used within every single method mPalindromes This vector will only be used in the MovePalindromes method Methods IsPalindromeNumber Checks to see if the value passed in is a palindrome or not This value can be any number of digits N A palindrome is any sequence that reads the same forwards and backwards Fill from file Fill the values vector with the contents of the binary file This file contains a fourbyte header section that represents the number of values to be read and stored in the vector Fill from array Fill the values vector with the contents of the passedin array Clear Removes all elements from the values vector Decreases the capacity of the vector to There are two methods within the vector class to handle this Sort Sorts the values vector, based on the value of the parameter Use the std::sort method to handle the sort Array Subscript operator Returns an individual element from the values vector No need for errorchecking, same as std::vector Contains Determines if a value is present in the values vector MovePalindromes The values vector is populated with a number of values. Iterate through this vector and move all of these values into the palindromes vector. This will require adding them to palindromes and erasing them from values Ensure that the order of the palindromes is the same Pseudocode o Iterate through the values vector If the value is a palindrome remember you have a method to check this Add it to the palindromes vector Remove it from the values vector
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
