File: array_dynamic.ck

package info (click to toggle)
chuck 1.5.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,056 kB
  • sloc: cpp: 123,473; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (31 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// instantiate int array
float argh[0];

// print out relevant info
<<< "array size:", argh.size() >>>;

// append items (array should grow dynamically as needed)
argh << 3.0 << 4 << 5;

// print out relevant info
<<< "array size:", argh.size() >>>;

// print out elements
<<< "contents:", argh[0], argh[1], argh[2] >>>;

// pop last element
argh.popBack();

// print out relevant info
<<< "array size:", argh.size() >>>;

argh << 6 << 7 << 8;

// pop middle element
argh.popOut(2);

// print array
<<< "printing remaining elements of array..." >>>;
for (0 => int i; i < argh.size(); i++) {
    <<< "elem", i, "-", argh[i] >>>;
}