The cached implementation for finding counter examples.

@see ModelChecker#findCounterExample(Object, Collection, Object)
432530
@Nullable
    @Override
    public R findCounterExample(A automaton, Collection<? extends I> inputs, P property) {
        if (automaton.size() > size) {
            counterExamples.clear();
        }

        size = automaton.size();

        return counterExamples.computeIfAbsent(
                Pair.of(inputs, property),
                key -> Optional.ofNullable(modelChecker.findCounterExample(automaton, inputs, property))).orElse(null);
    }
237161
private void countAndVerifyObjects()
                    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {
        println("countAndVerifyObjects(): Hashtable " + filename + " was not closed properly.  Validating ");
        header.set_num_objects(0);

        HashtableAction act = new HashtableAction() {
            public boolean execute(HashtableEntry e)
                            throws IOException
            {
                if ((header.num_objects() % 100) == 0) {
                    print(".");
                }
                header.incrementObjectCount();
                if (item_initialize != null) {
                    item_initialize.initialize(e.getKey(), e.getValue());
                }
                return true;
            }
        };

        walkHash(act, RETRIEVE_ALL, 0, -1);

        header.write();
        println("countAndVerifyObjects(): done");
    }
1299114
private int getCurrentValuesFromCache(List<CounterUpdateCell> counterUpdateCells,
                                          ColumnFamilyStore cfs,
                                          ClockAndCount[] currentValues)
    {
        int cacheMisses = 0;
        for (int i = 0; i < counterUpdateCells.size(); i++)
        {
            ClockAndCount cached = cfs.getCachedCounter(key(), counterUpdateCells.get(i).name());
            if (cached != null)
                currentValues[i] = cached;
            else
                cacheMisses++;
        }
        return cacheMisses;
    }
366294
private void updateInstances(List<InstanceContext> instances, final CountingCompletionHandler<Void> counter) {
    for (final InstanceContext instance : instances) {
      data.put(instance.address(), Contexts.serialize(instance).encode(), new Handler<AsyncResult<String>>() {
        @Override
        public void handle(AsyncResult<String> result) {
          if (result.failed()) {
            counter.fail(result.cause());
          } else {
            counter.succeed();
          }
        }
      });
    }
  }
522891
public static <T> int count(Iterable<T> iterable) {
        int count = 0;

        if (iterable != null) {
            Iterator<T> iter = iterable.iterator();
            while (iter.hasNext()) {
                iter.next();
                count++;
            }
        }

        return count;
    }
1132989
private static void getCounts(BaseArray T, BaseArray C, int n, int k) {
        for (int i = 0; i < k; ++i) {
            C.set(i, 0);
        }
        for (int i = 0; i < n; ++i) {
            C.update(T.get(i), 1);
        }
    }
248400
@Nullable
    @Override
    public DFALasso<I> findCounterExample(DFA<?, I> automaton, Collection<? extends I> inputs, String property)
            throws ModelCheckingException {
        final File fsm = findCounterExampleFSM(automaton, inputs, property);

        final DFALasso<I> result;

        if (fsm != null) {
            final CompactDFA<I> dfa;

            try {
                dfa = FSM2DFAParser.getParser(inputs, getString2Input(), LABEL_NAME, LABEL_VALUE).readModel(fsm);

                // check if we must keep the FSM
                if (!isKeepFiles() && !fsm.delete()) {
                    throw new ModelCheckingException("Could not delete file: " + fsm.getAbsolutePath());
                }
            } catch (IOException | FSMParseException e) {
                throw new ModelCheckingException(e);
            }

            result = new DFALassoImpl<>(dfa, dfa.getInputAlphabet(), computeUnfolds(automaton.size()));
        } else {
            result = null;
        }

        return result;
    }
92101
@VisibleForTesting
	protected Optional<CounterData> getCounterData(final String counterName)
	{
		Preconditions.checkNotNull(counterName);

		final Key<CounterData> counterKey = CounterData.key(counterName);
		final CounterData counterData = ObjectifyService.ofy().load().key(counterKey).now();

		return Optional.fromNullable(counterData);
	}
418750
@Override
    public int find(int x) {
        int curr = x;
        int currp = p[curr];
        while (curr != currp) {
            curr = currp;
            currp = p[curr];
        }
        int ancestor = curr;
        curr = x;
        while (curr != ancestor) {
            int next = p[curr];
            p[curr] = ancestor;
            curr = next;
        }

        return ancestor;
    }
892601
private Object count(ProceedingJoinPoint pjp, String aProducerId, String aSubsystem, String aCategory) throws Throwable {
		return perform(false,
				getMethodStatName(pjp.getSignature()),
				pjp,
				aProducerId,
				aCategory,
				aSubsystem);
				
	}
339966
public static int countParameterOfType(ModelMethod method, TypeName parameter) {
		int counter = 0;
		for (Pair<String, TypeName> item : method.getParameters()) {
			if (item.value1.equals(parameter)) {
				counter++;
			}
		}

		return counter;
	}
234925
protected int countCorrectPairs(MatchData data) 
	{
		// count the number of times each id appears in each source */
		Map counter = new HashMap();
		for (int i=0; i<data.numSources(); i++) {
			String src = data.getSource(i);
			for (int j=0; j<data.numInstances(src); j++){
				String id = data.getInstance(src, j).getId(); 
				if (id!=null) {
					IdKey key = new IdKey(id,src); 
					Integer c = (Integer)counter.get(key);
					counter.put( key, (c==null ? new Integer(1) : new Integer(c.intValue()+1)) );
				}
			}
		}

		/*
		// show the counter
		for (Iterator i=counter.keySet().iterator(); i.hasNext(); ) {
			IdKey key = (IdKey) i.next();
			System.out.println( key.src+"#"+key.id+" = "+counter.get(key) );
		}
		*/

		// count the number of correct pairs
		int numCorrectPairs = 0;
		Set idsInSrc1 = new HashSet();
		for (int i=0; i<data.numSources(); i++) {
			String src1 = data.getSource(i);
			idsInSrc1.clear();
			for (int j=0; j<data.numInstances(src1);j++) {
				String id = data.getInstance(src1, j).getId(); 
				idsInSrc1.add(id);
				for (int k=i+1; k<data.numSources(); k++) {
					String src2 = data.getSource(k);
					Integer cInteger = (Integer) counter.get( new IdKey(id,src2) );
					if (cInteger!=null) {
						numCorrectPairs += cInteger.intValue();
					}
					//System.out.println( "src1:"+src1+" id:"+id+" src2:"+src2+" c:"+cInteger); 
				}
			}
			if (clusterMode) {
				// count how often something in src1 can be matched correctly with something
				// else in src1
				for (Iterator j=idsInSrc1.iterator(); j.hasNext(); ) {
					String id = (String)j.next();
					Integer cInteger = (Integer) counter.get( new IdKey(id,src1) );
					int c = cInteger.intValue();
					numCorrectPairs += c*(c-1)/2;
				}
			}
		}
		return numCorrectPairs;
	}
548580
public final void hasCount(@NullableDecl Object element, int expectedCount) {
    checkArgument(expectedCount >= 0, "expectedCount(%s) must be >= 0", expectedCount);
    int actualCount = ((Multiset<?>) actual()).count(element);
    check("count(%s)", element).that(actualCount).isEqualTo(expectedCount);
  }
255929
public static <T> Map<T, Integer> countMap(Iterable<T> collection) {
		return IterUtil.countMap(collection);
	}
146457
public static int getCount(Matcher matcher) {
        int counter = 0;
        matcher.reset();
        while (matcher.find()) {
            counter++;
        }
        return counter;
    }
360464
public static <E> Map<E, Double> asMap(final Counter<E> counter) {
    return new AbstractMap<E, Double>() {
      @Override
      public int size() {
        return counter.size();
      }

      @Override
      public Set<Entry<E, Double>> entrySet() {
        return counter.entrySet();
      }

      @Override
      @SuppressWarnings("unchecked")
      public boolean containsKey(Object key) {
        return counter.containsKey((E) key);
      }

      @Override
      @SuppressWarnings("unchecked")
      public Double get(Object key) {
        return counter.getCount((E) key);
      }

      @Override
      public Double put(E key, Double value) {
        double last = counter.getCount(key);
        counter.setCount(key, value);
        return last;
      }

      @Override
      @SuppressWarnings("unchecked")
      public Double remove(Object key) {
        return counter.remove((E) key);
      }

      @Override
      public Set<E> keySet() {
        return counter.keySet();
      }
    };
  }
600455
public int countProtocolItems()
    throws MessageStoreException
  {
    if (tc.isEntryEnabled())  
      SibTr.entry(tc, "countProtocolItems");      

    int count = 0;
    
    NonLockingCursor cursor 
      = newNonLockingItemCursor(new ClassEqualsFilter(StreamSet.class));
           
    AbstractItem item = cursor.next();
    while (null != item)
    {
      //ProtocolItem protocolItem = (ProtocolItem)item;
      count++;
      item = cursor.next();
    }
 
    if (tc.isEntryEnabled())  
      SibTr.exit(tc, "countProtocolItems", new Integer(count));
            
    return count;
  }