jonvolfson / cs4500-api

0 stars 1 forks source link

Case where insert index is greater than length? #6

Closed barrylyung closed 4 years ago

barrylyung commented 4 years ago

I saw that you guys wanted to double the capacity of the array when it reaches the length. Did you implementation specify if there should be a resizing until the index is available for indexes > curr_length. Or was the assumption that it would be an Index out of bounds error.

In any case, can you add this specification to the tests?

jonvolfson commented 4 years ago

Hi Barry, we're still discussing between ourselves about how we want our resizing behavior to work. I initially thought they wanted us to resize the array down to be memory efficient but now the professor is telling us otherwise. We're probably leaning towards allowing the user to insert at any index >= 0 and if that exceeds the current length, keep doubling until that index exists. This is not really a clean solution but we don't understand what their requirements for expandable arrays are.

We'll add to the test and keep you updated after they clarify on piazza.

jonvolfson commented 4 years ago

We are planning to ask the professor during class tomorrow for more insight on what they expect for array functionality. Sorry if this affects your timeline but we don't want to write code that they could possibly tell us is invalid tomorrow.

jonvolfson commented 4 years ago

Insert is now only allowed between indices 0 and length-1. We would like an error to print out when they try to insert out of bounds. Whether the program quits or not is up to you.

barrylyung commented 4 years ago

Can you update the tests to reflect this behavior. Such that when used insert() and it reaches capacity, it should not resize - correct? This is reflected in test 3:

t_true(a1->length() == 4); // when reaching max capacity, resize the array

testing dynamic add
a1->insert(new int(20), 2);
t_true(a1->count() == 3);