tools/jprof/intcnt.h
author Xidorn Quan <quanxunzhen@gmail.com>
Tue, 08 Sep 2015 10:00:06 +1000
changeset 290877 2b00eb9728c599b45ca24ca23f693283d79973cc
parent 129337 931e85b3d576d5971e7c02896dade6ce9a57fc44
child 489668 cbb8fdf1daf98a15f7d57f6b08d273bdf96aa1a0
child 694109 98e2b4ee9775a2a2b5cc1bb8a390bfe901814f38
permissions -rw-r--r--
Bug 1126230 part 11 - Add test for fullscreen top layer.

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef INTCNT_H
#define INTCNT_H

class IntCount
{
public:
    IntCount();
    ~IntCount();
    void clear();
    int countAdd(int index, int increment=1);
    int countGet(int index);
    int getSize();
    int getCount(int pos);
    int getIndex(int pos);

    IntCount(const IntCount&old)
    {
      numInts = old.numInts;
      if (numInts > 0) {
        iPair = new IntPair[numInts];
        for (int i = 0; i < numInts; i++) {
          iPair[i] = old.iPair[i];
        }
      } else {
        iPair = nullptr;
      }
    }
private:

    int    numInts;
    struct IntPair{int idx; int cnt;} *iPair;
};

#endif