File: test.C

package info (click to toggle)
rosegarden 1%3A1.4.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 23,188 kB
  • ctags: 15,707
  • sloc: cpp: 148,264; xml: 4,687; python: 1,946; makefile: 1,146; perl: 1,033; sh: 587; ansic: 337; ruby: 173
file content (45 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// -*- c-basic-offset: 4 -*-


#include "../FastVector.h"
#include <iostream>

class Thing
{
public:
    Thing(int x) : m_x(x) { }
    ~Thing() { }

    int getX() const { return m_x; }

private:
    int m_x;
};

main()
{
    FastVector<Thing> v;

    for (int i = 0; i < 20; ++i) {
        v.push_back(Thing(i * 2));
        v.push_front(Thing(i));
    }

    for (int i = 0; i < v.size(); ++i) {
        std::cout << "v[" << i << "] is " << v[i].getX() << std::endl;
    }

    const FastVector<Thing> *w = &v;

    for (FastVector<Thing>::const_iterator j = w->begin(); j != w->end(); ++j) {
        std::cout << "item is " << j->getX() << std::endl;
    }

    std::cout << std::endl;

    for (FastVector<Thing>::reverse_iterator rj = v.rbegin();
         rj != v.rend(); ++rj) {
        std::cout << "item is " << rj->getX() << std::endl;
    }
}