michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "intcnt.h" michael@0: michael@0: IntCount::IntCount() : numInts(0), iPair(nullptr) { } michael@0: IntCount::~IntCount() { delete [] iPair;} michael@0: int IntCount::getSize() {return numInts;} michael@0: int IntCount::getCount(int pos) {return iPair[pos].cnt;} michael@0: int IntCount::getIndex(int pos) {return iPair[pos].idx;} michael@0: michael@0: void IntCount::clear() michael@0: { michael@0: delete[] iPair; michael@0: iPair = new IntPair[0]; michael@0: numInts = 0; michael@0: } michael@0: michael@0: int IntCount::countAdd(int index, int increment) michael@0: { michael@0: if(numInts) { michael@0: // Do a binary search to find the element michael@0: int divPoint = 0; michael@0: michael@0: if(index>iPair[numInts-1].idx) { michael@0: divPoint = numInts; michael@0: } else if(indexiPair[mid].idx) { michael@0: if(mid