In this solution, the functions with small, fast implementations are inlined. Alternatively, the inlinekeyword can be removed and the function definitions moved to Sequence.cpp.

computer science

Description

In this solution, the functions with small, fast implementations are inlined. Alternatively, the inlinekeyword can be removed and the function definitions moved to Sequence.cpp. (inline will be mentioned at some point in class, so don't worry if you've never seen it before.) 


Notice which member functions are const, and observe the use of the type alias ItemTy


// Later in the course, we'll see that templates provide a much nicer 

// way of enabling us to have Sequences of different types. For now,

 // we'll use a type alias


int insert(int pos, const ItemType& value); 

// Insert value into the sequence so that it becomes the item at 

// position pos. The original item at position pos and those that 

// follow it end up at positions one higher than they were at before. 

// Return pos if 0 <= pos <= size() and the value could be

// inserted. (It might not be, if the sequence has a fixed capacity, 

// e.g., because it's implemented using a fixed-size array.) Otherwise, 

// leave the sequence unchanged and return -1. Notice that 

// if pos is equal to size(), the value is inserted at the end. 


Instruction Files

Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.