// CounterForDimension returns a CountTracker for the provided
// dimension. It will panic if the dimension isn't a legal label for
// mt.
768164
func CounterForDimension(mt MultiTracker, dimension string) CountTracker {
	for i, lab := range mt.Labels() {
		if lab == dimension {
			return wrappedCountTracker{
				f: func() map[string]int64 {
					result := make(map[string]int64)
					for k, v := range mt.Counts() {
						if k == "All" {
							result[k] = v
							continue
						}
						result[strings.Split(k, ".")[i]] += v
					}
					return result
				},
			}
		}
	}

	panic(fmt.Sprintf("label %v is not one of %v", dimension, mt.Labels()))
}
364863
func (t TimeUnit) Count(c CountUnit, dimension int8) MetricUnit {
	return (&metricUnit{uint32(t)}).Count(c, dimension)
}
239841
func NewCounterFunc(name string, help string, f func() int64) *CounterFunc {
	c := &CounterFunc{
		F:    f,
		help: help,
	}

	if name != "" {
		publish(name, c)
	}
	return c
}
223523
func (c *Counters) String() string {
	c.mu.Lock()
	defer c.mu.Unlock()
	return counterToString(c.counts)
}
1366833
func (b *Bucket) CounterDura(key string, delta, initial int64, expiry uint32, replicateTo, persistTo uint) (uint64, Cas, error) {
	val, cas, mt, err := b.counter(key, delta, initial, expiry)
	if err != nil {
		return val, cas, err
	}
	return val, cas, b.durability(key, cas, mt, replicateTo, persistTo, false)
}
56643
func (counter *rayCrossingCounter) countSegment(p1, p2 geom.Coord) {
	/**
	 * For each segment, check if it crosses
	 * a horizontal ray running from the test point in the positive x direction.
	 */

	// check if the segment is strictly to the left of the test point
	if p1[0] < counter.p[0] && p2[0] < counter.p[0] {
		return
	}

	// check if the point is equal to the current ring vertex
	if counter.p[0] == p2[0] && counter.p[1] == p2[1] {
		counter.isPointOnSegment = true
		return
	}

	/**
	 * For horizontal segments, check if the point is on the segment.
	 * Otherwise, horizontal segments are not counted.
	 */
	if p1[1] == counter.p[1] && p2[1] == counter.p[1] {
		minx := p1[0]
		maxx := p2[0]
		if minx > maxx {
			minx = p2[0]
			maxx = p1[0]
		}
		if counter.p[0] >= minx && counter.p[0] <= maxx {
			counter.isPointOnSegment = true
		}
		return
	}
	/**
	 * Evaluate all non-horizontal segments which cross a horizontal ray to the
	 * right of the test pt. To avoid double-counting shared vertices, we use the
	 * convention that
	 * <ul>
	 * <li>an upward edge includes its starting endpoint, and excludes its
	 * final endpoint
	 * <li>a downward edge excludes its starting endpoint, and includes its
	 * final endpoint
	 * </ul>
	 */
	if ((p1[1] > counter.p[1]) && (p2[1] <= counter.p[1])) || ((p2[1] > counter.p[1]) && (p1[1] <= counter.p[1])) {
		// translate the segment so that the test point lies on the origin
		x1 := p1[0] - counter.p[0]
		y1 := p1[1] - counter.p[1]
		x2 := p2[0] - counter.p[0]
		y2 := p2[1] - counter.p[1]

		/**
		 * The translated segment straddles the x-axis. Compute the sign of the
		 * ordinate of intersection with the x-axis. (y2 != y1, so denominator
		 * will never be 0.0)
		 */
		// double xIntSign = RobustDeterminant.signOfDet2x2(x1, y1, x2, y2) / (y2
		// - y1);
		// MD - faster & more robust computation?
		xIntSign := robustdeterminate.SignOfDet2x2(x1, y1, x2, y2)
		if xIntSign == 0.0 {
			counter.isPointOnSegment = true
			return
		}
		if y2 < y1 {
			xIntSign = -xIntSign
		}
		// xsave = xInt;

		// System.out.println("xIntSign(" + x1 + ", " + y1 + ", " + x2 + ", " + y2 + " = " + xIntSign);
		// The segment crosses the ray if the sign is strictly positive.
		if xIntSign > 0.0 {
			counter.crossingCount++
		}
	}
}
247330
func (i *Index) DropMeasurementIfSeriesNotExist(name []byte) error {
	// Check if that was the last series for the measurement in the entire index.
	if ok, err := i.MeasurementHasSeries(name); err != nil {
		return err
	} else if ok {
		return nil
	}

	// If no more series exist in the measurement then delete the measurement.
	return i.DropMeasurement(name)
}
233503
func NewCounterFunc(opts prometheus.CounterOpts, function func() float64) prometheus.CounterFunc {
	g := prometheus.NewCounterFunc(opts, function)
	prometheus.MustRegister(g)
	return g
}
1011315
func GetCounterValue(m prometheus.Counter) float64 {
	var pm dto.Metric
	err := m.Write(&pm)
	if err == nil {
		return *pm.Counter.Value
	}
	return 0
}
223569
func (j *jumpMap) countJumpsFrom(c *compilerContext, jumpTarget, expectedFrom int) int {
	count := 0

	for _, ll := range c.labels.labelsAt(jumpTarget) {
		for _, xx := range j.labelToPosition[ll] {
			if xx == expectedFrom {
				count++
			}
		}
	}

	return count
}
467225
func IncrementCounter(name string) error {
	if metricSender == nil {
		return nil
	}
	return metricSender.IncrementCounter(name)
}
1215722
func (m *Column) CountStar() bool {
	if m.Expr == nil {
		return false
	}
	if fn, ok := m.Expr.(*expr.FuncNode); ok {
		if len(fn.Args) != 1 {
			return false
		}
		return strings.ToLower(fn.Name) == "count" && fn.Args[0].String() == `*`
	}
	return false
}
1316288
func (st *State) CountOfSentMetrics() (int, error) {
	c, closer := st.db().GetCollection(metricsC)
	defer closer()
	return c.Find(bson.M{
		"model-uuid": st.ModelUUID(),
		"sent":       true,
	}).Count()
}
196583
func NewCounterDuration(name, help string) *CounterDuration {
	cd := &CounterDuration{
		help: help,
	}
	publish(name, cd)
	return cd
}
532596
func (a *Driver) CounterClockwise(speed int) {
	a.adaptor().drone.CounterClockwise(speed)
}
714121
func (c Counter) SetFunc(f func() uint64) {
	cm.Lock()
	defer cm.Unlock()

	counterFuncs[string(c)] = f
}
1018164
func (c *Counters) Counts() map[string]int64 {
	c.mu.Lock()
	defer c.mu.Unlock()

	counts := make(map[string]int64, len(c.counts))
	for k, v := range c.counts {
		counts[k] = v
	}
	return counts
}