Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
notsosimplevector.cc
Go to the documentation of this file.
1#include "lout/misc.hh"
2
4{
5 for (int i = 0; i < v->size(); i++) {
6 // Uncomment for debugging, after making the respective members public.
7 //if (v->startExtra != -1 && i == v->startExtra + v->numExtra)
8 // printf (" ]");
9 if (i > 0)
10 printf (", ");
11 //if (i == v->startExtra)
12 // printf ("[ ");
13
14 printf ("%d", v->get(i));
15 }
16
17 printf (" (%d elements)\n", v->size ());
18}
19
20int main (int argc, char *argv[])
21{
23
24 for (int i = 1; i <= 10; i++) {
25 v.increase ();
26 v.set(v.size () - 1, i);
27 }
28
29 print (&v);
30
31 v.insert (2, 4);
32 for (int i = 0; i < 5; i++)
33 v.set (2 + i, 31 + i);
34
35 print (&v);
36
37 v.insert (8, 4);
38 for (int i = 0; i < 5; i++)
39 v.set (8 + i, 51 + i);
40
41 print (&v);
42
43 v.insert (10, 4);
44 for (int i = 0; i < 5; i++)
45 v.set (10 + i, 531 + i);
46
47 print (&v);
48
49 v.insert (1, 4);
50 for (int i = 0; i < 5; i++)
51 v.set (1 + i, 21 + i);
52
53 print (&v);
54
55 int n = v.size ();
56 v.insert (n, 5);
57 for (int i = 0; i < 5; i++)
58 v.set (n + i, 101 + i);
59
60 print (&v);
61
62 return 0;
63}
int main(void)
Definition bookmarks.c:1613
Container similar to lout::misc::SimpleVector, but some cases of insertion optimized (used for hyphen...
Definition misc.hh:332
void set(int i, T t)
Store an object in the vector.
Definition misc.hh:554
void insert(int index, int numInsert)
Definition misc.hh:420
T get(int i) const
Return the one element, explicitly.
Definition misc.hh:511
static void print(lout::misc::NotSoSimpleVector< int > *v)