tools/jprof/intcnt.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/jprof/intcnt.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef INTCNT_H
     1.9 +#define INTCNT_H
    1.10 +
    1.11 +class IntCount
    1.12 +{
    1.13 +public:
    1.14 +    IntCount();
    1.15 +    ~IntCount();
    1.16 +    void clear();
    1.17 +    int countAdd(int index, int increment=1);
    1.18 +    int countGet(int index);
    1.19 +    int getSize();
    1.20 +    int getCount(int pos);
    1.21 +    int getIndex(int pos);
    1.22 +
    1.23 +    IntCount(const IntCount&old)
    1.24 +    {
    1.25 +      numInts = old.numInts;
    1.26 +      if (numInts > 0) {
    1.27 +        iPair = new IntPair[numInts];
    1.28 +        for (int i = 0; i < numInts; i++) {
    1.29 +          iPair[i] = old.iPair[i];
    1.30 +        }
    1.31 +      } else {
    1.32 +        iPair = nullptr;
    1.33 +      }
    1.34 +    }
    1.35 +private:
    1.36 +
    1.37 +    int    numInts;
    1.38 +    struct IntPair{int idx; int cnt;} *iPair;
    1.39 +};
    1.40 +
    1.41 +#endif

mercurial