List of utility methods to do Collection Count
int | count(Collection collection) count if (isEmpty(collection)) return 0; return collection.size(); |
Map | count(Collection collection) Returns a map where each entry represents the number of times that the corresponding key appears in the input collection. Map<A, Integer> out = new LinkedHashMap<A, Integer>(); for (A value : collection) out.put(value, out.containsKey(value) ? out.get(value) + 1 : 1); return out; |
int | count(Collection count int out = 0; for (T t : ts) if (t.equals(toCount)) out++; return out; |
int | count(final Collection extends ItemType> collection, final ItemType item) count int counter = 0; for (final ItemType itemType : collection) { if (itemType == item) { counter++; return counter; |
long | count(final Collection TODO if (blocks == null || blocks.isEmpty()) { return 0L; return blocks.stream().mapToLong(block -> block.length).sum(); |
Double | count(T x0, T x1, T x2, Collection count Double count = 0d; for (T[] sentence : sentences) { int idx0 = contains(sentence, x0); if (idx0 >= 0) { if (idx0 + 2 < sentence.length && x1.equals(sentence[idx0 + 1]) && x2.equals(sentence[idx0 + 2])) { count++; return count; |
int | count(V matching, Collection count int count = 0; for (V value : values) { if (matching.equals(value)) { count++; return count; |
int | countCollectionsSize(Collection... cols) count Collections Size int totalSize = 0; if (cols == null || cols.length < 1) return totalSize; for (Collection oneList : cols) { if (oneList == null) continue; totalSize += oneList.size(); return totalSize; |
int | countComplement(Collection extends T> s1, Collection extends T> s2) count Complement int n1 = s1.size(); int n2 = s2.size(); if (n2 < n1) { Collection<? extends T> t = s1; s1 = s2; s2 = t; int n = s2.size() - s1.size(); ... |
List | countDuplicates(Collection count Duplicates List<T> itemSet = new ArrayList<T>(); for (T item : items) { if (!itemSet.contains(item)) { itemSet.add(item); Object[] params = new Object[itemSet.size()]; int n = 0; ... |