jameshughes89 / cs102

CS 102: Data Structures --- Java
http://csci162.com/
GNU General Public License v3.0
11 stars 16 forks source link

:lipstick: :technologist: `expandCapacity` --- Return array #952

Closed jameshughes89 closed 8 months ago

jameshughes89 commented 8 months ago

Related Issues or PRs

https://github.com/jameshughes89/cs102-assignments/pull/136

Closes #800

What

Change the expandCapacity methods to return a new array instead of being all side-effect-ie

Why

From #800

  1. Side effects are annoying
  2. I have talked about side effects being annoying, yet I am very explicitly using one here
  3. It will be more similar to the Arrays.copyOf method that I switch to with the bags

How

Used the find thing in intelliJ

Testing

:+1:

Additional Notes

I think I caught all mentions of this, but I will not be shocked if I somehow missed some reference to this in the content. I'll keep my eyes open. Indirect references to this could have been missed.

jameshughes89 commented 8 months ago

The way expandCapacity was discussed in the course notes was done in such a way that it required minimal changes, which was nice.

twentylemon commented 8 months ago

instead of being all side-effect-ie

Just ignore the whole stack interface.