fix: correcting a mistake in c vector doc

This commit is contained in:
Lucien Cartier-Tilet 2023-10-27 15:40:30 +02:00
parent f77a1ebcd2
commit 77c1184049
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 2 additions and 2 deletions

View File

@ -446,13 +446,13 @@ then a sixteen-slots array. And in a couple more calls to ~realloc~,
well quickly reach our tens of thousands slots array, way faster than well quickly reach our tens of thousands slots array, way faster than
by incrementing its capacity one by one. by incrementing its capacity one by one.
/“But, well end up with a lot of unused memory if we need just one more element than 2^{16} elements! We dont need a 2^{32} elements array for 2^{16}+1 elements!”/ /“But, well end up with a lot of unused memory if we need just one more element than 2^{16} elements! We dont need a 2^{17} elements array for 2^{16}+1 elements!”/
Youre completely right, but thats a tradeoff. Would you rather have Youre completely right, but thats a tradeoff. Would you rather have
a slow but memory-efficient program, or a fast but memory-hungry a slow but memory-efficient program, or a fast but memory-hungry
software? Plus, as youll see later, there is a function to shrink the software? Plus, as youll see later, there is a function to shrink the
size of the allocated array down to the actual amount of elements you size of the allocated array down to the actual amount of elements you
stored in it, making it possible to temporarily have a 2^{32} elements stored in it, making it possible to temporarily have a 2^{17} elements
array, and immediately after shrink it down to 2^{16}+1, once you know array, and immediately after shrink it down to 2^{16}+1, once you know
you wont be adding any other elements. you wont be adding any other elements.