46 lines · 1.1 KB · Text
RawDownload
// name: array_resize.ck// desc: this demonstrates how array resize and clear;//       also see: array_capacity.ck//       modified: 1.4.1.0 (ge)////       (NOTE: .capacity() is not the same as .cap(); the latter is//       maintained for historical / compatibility reasons; .cap()//       actually is the same as .size() -- which is rather confusing!////       It is strongly recommended that .cap() be avoided; instead,//       explicitly use .size() or .capacity() as appropriate.) // instantiate a float arrayfloat argh[0]; // print<<< "array size:", argh.size(), "capacity:", argh.capacity() >>>; // resize4 => argh.size; // print<<< "array size:", argh.size(), "capacity:", argh.capacity() >>>; // set elements3.0 => argh[0];4 => argh[1];5.0 => argh[2];6 => argh[3]; // print<<< "contents:", "">>>;for( int i; i < argh.size(); i++ )    <<< "argh[", i, "]:", argh[i] >>>; // recap2 => argh.size; // print<<< "array size:", argh.size(), "capacity:", argh.capacity() >>>; // clear the contentsargh.clear(); // print<<< "array size:", argh.size(), "capacity:", argh.capacity() >>>;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t