/* Helper to simpleGoodTuringSmoothedCounter()
482837
private static <E> void validateCounter(Counter<E> counts) {
    for (Map.Entry<E, Double> entry : counts.entrySet()) {
      E item = entry.getKey();
      Double dblCount = entry.getValue();
      if (dblCount == null) {
        throw new IllegalArgumentException("ERROR: null count for item " + item + "!");
      }
      if (dblCount < 0) {
        throw new IllegalArgumentException("ERROR: negative count " + dblCount + " for item " + item + "!");
      }
    }
  }
1091067
function makeCounterMap() {
  var map = new WeakMap();
  return {
    init(obj) { map.set(obj, 0); },
    incr(obj) {
      console.assert(map.has(obj), "Object must be in counter map.");
      map.set(obj, map.get(obj) + 1);
    },
     get(obj)  { return map.get(obj); }
  };
}
844860
public Integer getCountAtOrAbove(final long version) {
        if (versionsStored < versionWindow.length) {
            return null;
        }
        int count = 0;
        for (int versionIdx = 0; versionIdx < versionWindow.length; versionIdx++) {
            if (versionWindow[versionIdx] >= version) {
                count++;
            }
        }

        return count;
    }
323724
function counter(state = 0, action = {}) {
  switch (action.type) {
    case INCREMENT_COUNTER:
      return state + 1;
    case DECREMENT_COUNTER:
      return state - 1;
    default:
      return state;
  }
}
585717
function countTrailingZeros(v) {
  var c = 32;
  v &= -v;
  if (v) c--;
  if (v & 0x0000FFFF) c -= 16;
  if (v & 0x00FF00FF) c -= 8;
  if (v & 0x0F0F0F0F) c -= 4;
  if (v & 0x33333333) c -= 2;
  if (v & 0x55555555) c -= 1;
  return c;
}
514590
private GeneralizedCounter<K> conditionalizeHelper(K o) {
    if (depth > 1) {
      GeneralizedCounter<K> next = ErasureUtils.<GeneralizedCounter<K>>uncheckedCast(map.get(o));
      if (next == null) // adds a new GeneralizedCounter if needed
      {
        map.put(o, (next = new GeneralizedCounter<K>(depth - 1)));
      }
      return next;
    } else {
      throw new RuntimeException("Error -- can't conditionalize a distribution of depth 1");
    }
  }
922099
private void countCoordinates(int xCoord, int yCoord,
			ItemDocument itemDocument) {

		for (String siteKey : itemDocument.getSiteLinks().keySet()) {
			Integer count = this.siteCounts.get(siteKey);
			if (count == null) {
				this.siteCounts.put(siteKey, 1);
			} else {
				this.siteCounts.put(siteKey, count + 1);
			}
		}

		for (ValueMap vm : this.valueMaps) {
			vm.countCoordinates(xCoord, yCoord, itemDocument);
		}
	}
955822
function _count(self, usingSkipAndLimit, callback) {
    if (typeof callback !== 'function') throw new Error("callback is not a function!")
    var query = { count: self.collection.name }
    if (self.criteria) {
        query.query = self.criteria
    }
    if (usingSkipAndLimit) {
        query.skip = self._skip || 0
        query.limit = self._limit
    }
    self.db.runCommand(query, safetyNet(callback, function(result) {
        callback(null, result.n)
    }))
}
355594
@Override
	public int countCases() {
		int counter = 1;
		for (Constraint c : map.values()) {
			counter = Math.max(counter, c.countCases());
		}
		return counter;
	}
691472
function isCounterAfter(counter, currentStateCounter)
{
	const diff = counter - currentStateCounter

	// If the new options are "newer" than the current ones,
	// then they can override them.
	// (also accounts for counter overflow)
	return diff > 0 || (diff < 0 && Math.abs(diff) > MAX_SAFE_INTEGER / 2)
}
858736
function tally(pathname, offenses) {
    var count = offenses.length,
        plural = count > 1 ? 'errors' : 'error';

    function perOffense(o) {
        if (!errors[pathname]) {
            errors[pathname] = [];
        }

        if (o) {
            errors[pathname].push({
                line: o.line,
                col: o.character,
                msg: o.reason,
                evidence: o.evidence || ''
            });
        }
    }

    log.error([count, plural, 'in', pathname].join(' '));
    offenses.forEach(perOffense);
}
1111554
public void count(final Stat name, final int count) {
        Integer value = counters.get(name);
        value = value == null ? count : value + count;
        counters.put(name, value);
    }
188804
public void incrementCount2D(K first, K second, double count) {
    if (depth != 2) {
      wrongDepth(); //throws exception
    }

    this.addToTotal(count);
    GeneralizedCounter<K> next = this.conditionalizeHelper(first);
    next.incrementCount1D(second, count);
  }
1141958
public void incrementCounter(BugChecker bugChecker, String key, int count) {
    statisticsCollector.incrementCounter(statsKey(bugChecker.canonicalName() + "-" + key), count);
  }
669126
function Counter() {
  this.total = 0;
  this.executed = 0;
  this.passed = 0;
  this.error = 0;
  this.failed = 0;
  this.timeout = 0;
  this.aborted = 0;
  this.inconclusive = 0;
  this.passedButRunAborted = 0;
  this.notRunnable = 0;
  this.notExecuted = 0;
  this.disconnected = 0;
  this.warning = 0;
  this.completed = 0;
  this.inProgress = 0;
  this.pending = 0;
}
250808
function wrapCountingMethod(method) {
  DruidNode.prototype[method] = function() {
    var self = this
      , args = utils.args(arguments, 0)
      , callback = args.pop()

    self.active++

    debug('Active calls to Druid node ' + this.data.id + ': ' + this.active)

    function wrapper() {
      self.active--

      callback.apply(null, arguments)
    }

    args.push(wrapper)

    Client.prototype[method].apply(this, args)
  }
}
1140820
function makeCountNCallback(n, cb) {
        var count = 0,
            results = [],
            error;
        return function(index, err, result) {
            results[index] = result;
            if (!error && err) {
                error = err;
                return cb(err);
            }
            if (!error && ++count == n) {
                cb(null, results);
            }
        };
    }