diff -r 000000000000 -r 6474c204b198 tools/jprof/intcnt.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/jprof/intcnt.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,71 @@ +/* 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/. */ + +#include "intcnt.h" + +IntCount::IntCount() : numInts(0), iPair(nullptr) { } +IntCount::~IntCount() { delete [] iPair;} +int IntCount::getSize() {return numInts;} +int IntCount::getCount(int pos) {return iPair[pos].cnt;} +int IntCount::getIndex(int pos) {return iPair[pos].idx;} + +void IntCount::clear() +{ + delete[] iPair; + iPair = new IntPair[0]; + numInts = 0; +} + +int IntCount::countAdd(int index, int increment) +{ + if(numInts) { + // Do a binary search to find the element + int divPoint = 0; + + if(index>iPair[numInts-1].idx) { + divPoint = numInts; + } else if(indexiPair[mid].idx) { + if(mid