Assignment 1 - arraylist_insert() clarification

123 views
Skip to first unread message

Hou In (Ivan) Tam

unread,
Sep 23, 2020, 6:50:03 AM9/23/20
to cmpt-295-sfu
SFU ID: 301417569
Github username: Iv-T
Line and file: N/A
Expected behavior: N/A
Observed behavior: N/A
Question:

This is the description of the insert function on the course website:

This function should take advantage of your arraylist_add to insert an element at an arbitrary location in your arraylist. You do not have to worry about attempting to insert to locations beyond the end of the arraylist (doing so it undefined behavior). Hint: Use memmove()

Is "beyond the end" talking about the length (no. of item in the arraylist) or the buffer_size (capacity of the arraylist)? 


Hou In (Ivan) Tam

unread,
Sep 23, 2020, 1:41:07 PM9/23/20
to cmpt-295-sfu
Want to make the question more clear:
If we have the following arraylist, will the user insert an item at index 6? (resulting in unused slots between index 3 and 6.) Do we have to take care of this use case?
example.png

Arrvindh Shriraman

unread,
Sep 23, 2020, 4:43:24 PM9/23/20
to cmpt-295-sfu
You do not have to worry about attempting to insert to locations beyond the end of the arraylist (doing so it undefined behavior).
Reply all
Reply to author
Forward
0 new messages