Creates a new TwoDimensionalCounter where all the counts are scaled by d.
Internally, uses Counters.scale();

@return The TwoDimensionalCounter
490955
public static <T1, T2> TwoDimensionalCounter<T1, T2> scale(TwoDimensionalCounter<T1, T2> c, double d) {
    TwoDimensionalCounter<T1, T2> result = new TwoDimensionalCounter<T1, T2>(c.getOuterMapFactory(), c.getInnerMapFactory());
    for (T1 key : c.firstKeySet()) {
      ClassicCounter<T2> ctr = c.getCounter(key);
      result.setCounter(key, scale(ctr, d));
    }
    return result;
  }
790224
private int getShouldDrawCount(){
        if(mPager.getAdapter() instanceof InfinitePagerAdapter){
            return ((InfinitePagerAdapter)mPager.getAdapter()).getRealCount();
        }else{
            return mPager.getAdapter().getCount();
        }
    }
1128660
@SuppressWarnings( { "unchecked" })
  public static <K1, K2> TwoDimensionalCounter<K2, K1> reverseIndexOrder(TwoDimensionalCounter<K1, K2> cc) {
    // they typing on the outerMF is violated a bit, but it'll work....
    TwoDimensionalCounter<K2, K1> result = new TwoDimensionalCounter<K2, K1>((MapFactory) cc.outerMF,
        (MapFactory) cc.innerMF);

    for (K1 key1 : cc.firstKeySet()) {
      ClassicCounter<K2> c = cc.getCounter(key1);
      for (K2 key2 : c.keySet()) {
        double count = c.getCount(key2);
        result.setCount(key2, key1, count);
      }
    }
    return result;
  }
1128627
protected StrongCounter getCounterOrCreateIt(String counterName, int initialValue) {
		CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager( cacheManager );
		if ( !counterManager.isDefined( counterName ) ) {
			LOG.tracef( "Counter %s is not defined, creating it", counterName );

			// global configuration is mandatory in order to define
			// a new clustered counter with persistent storage
			validateGlobalConfiguration();

			counterManager.defineCounter( counterName,
				CounterConfiguration.builder(
					CounterType.UNBOUNDED_STRONG )
						.initialValue( initialValue )
						.storage( Storage.PERSISTENT )
						.build() );
		}

		StrongCounter strongCounter = counterManager.getStrongCounter( counterName );
		return strongCounter;
	}
1183081
public static IntegerArrayIterator createFromKeyPrefix(int[] dimensionSizes, int[] keyPrefix) {    
    int[] sizesForIteration = new int[dimensionSizes.length - keyPrefix.length];
    for (int i = keyPrefix.length; i < dimensionSizes.length; i++) {
      sizesForIteration[i - keyPrefix.length] = dimensionSizes[i];
    }
    return new IntegerArrayIterator(sizesForIteration, keyPrefix);
  }
1241480
public static <T1, T2> void addInPlace(TwoDimensionalCounter<T1, T2> target, TwoDimensionalCounter<T1, T2> arg, double scale) {
    for (T1 outer : arg.firstKeySet())
      for (T2 inner : arg.secondKeySet()) {
        target.incrementCount(outer, inner, scale * arg.getCount(outer, inner));
      }
  }
269788
public Map<L,Counter<F>> weightsAsMapOfCounters() {
    Map<L,Counter<F>> mapOfCounters = new HashMap<L,Counter<F>>();
    for(L label : labelIndex){
      int labelID = labelIndex.indexOf(label);
      Counter<F> c = new ClassicCounter<F>();
      mapOfCounters.put(label, c);
      for (F f : featureIndex) {
        c.incrementCount(f, weights[featureIndex.indexOf(f)][labelID]);
      }
    }
    return mapOfCounters;
  }
130397
public static <N> HCounterColumn<N> createCounterColumn(N name, long value, Serializer<N> nameSerializer) {
    return new HCounterColumnImpl<N>(name, value, nameSerializer);
  }
1010657
public static SiblingCounter create( final ChildReferences childRefs ) {
        assert childRefs != null;
        return new SiblingCounter() {
            @Override
            public int countSiblingsNamed( Name childName ) {
                return childRefs.getChildCount(childName);
            }
        };
    }
609703
public static <E> Counter<E> division(Counter<E> c1, Counter<E> c2) {
    Counter<E> result = c1.getFactory().create();
    for (E key : Sets.union(c1.keySet(), c2.keySet())) {
      result.setCount(key, c1.getCount(key) / c2.getCount(key));
    }
    return result;
  }
556450
private void createCountersManager() {
        UnsafeBuffer counterLabelsBuffer = monitorFileWriter.createGatewayCounterLabelsBuffer();
        UnsafeBuffer counterValuesBuffer = monitorFileWriter.createGatewayCounterValuesBuffer();

        countersManager = new CountersManager(counterLabelsBuffer, counterValuesBuffer);
    }
987782
public AbstractCounterFactory init() {
        int numProcessors = Runtime.getRuntime().availableProcessors();
        counterCache = CacheBuilder.newBuilder().concurrencyLevel(Math.max(numProcessors, 8))
                .expireAfterAccess(3600, TimeUnit.SECONDS)
                .removalListener(new RemovalListener<String, ICounter>() {
                    @Override
                    public void onRemoval(RemovalNotification<String, ICounter> notification) {
                        ICounter counter = notification.getValue();
                        destroyCounter(counter);
                    }
                }).build(new CacheLoader<String, ICounter>() {
                    @Override
                    public ICounter load(String key) throws Exception {
                        return createCounter(key);
                    }
                });
        return this;
    }
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);
  }
94678
public double count() {
        T obj2 = ref.get();
        return obj2 != null ? (lastCount = Math.max(countFunction.applyAsLong(obj2), 0)) : lastCount;
    }
1355150
public static <T1, T2> Counter<T2> transform(Counter<T1> c, Function<T1, T2> f) {
    Counter<T2> c2 = new ClassicCounter<T2>();
    for (T1 key : c.keySet()) {
      c2.setCount(f.apply(key), c.getCount(key));
    }
    return c2;
  }
670642
public Iterator<T> iterator() {
        List<Iterator<T>> iters = new ArrayList<Iterator<T>>(sets.size());
        for (Set<T> s : sets)
            iters.add(s.iterator());
        return new CombinedIterator<T>(iters);
    }
149784
private static <E> Counter<Integer> collectCountCounts(Counter<E> counts) {
    Counter<Integer> cc = new ClassicCounter<Integer>(); // counts of counts
    for (Map.Entry<E, Double> entry : counts.entrySet()) {
      //E item = entry.getKey();
      Integer count = (int) Math.round(entry.getValue());
      cc.incrementCount(count);
    }
    return cc;
  }