MCPcopy Create free account
hub / github.com/davidgiven/luje / frequency

Method frequency

lib/java/util/Collections.java:2456–2472  ·  view source on GitHub ↗

Returns the number of elements in the Collection that match the Object passed. If the Object is null, then the number of null elements is returned. @param c the Collection to search. @param o the Object to search for. @re

(Collection<?> c, Object o)

Source from the content-addressed store, hash-verified

2454 * @since 1.5
2455 */
2456 public static int frequency(Collection<?> c, Object o) {
2457 if (c == null) {
2458 throw new NullPointerException();
2459 }
2460 if (c.isEmpty()) {
2461 return 0;
2462 }
2463 int result = 0;
2464 Iterator<?> itr = c.iterator();
2465 while (itr.hasNext()) {
2466 Object e = itr.next();
2467 if (o == null ? e == null : o.equals(e)) {
2468 result++;
2469 }
2470 }
2471 return result;
2472 }
2473
2474 /**
2475 * Returns a type-safe empty, immutable {@link List}.

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.65
iteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected