List of utility methods to do List Count
int | count(List l, int from, int to, Object what) count the number of occurences in a list int result = 0; while (from < to) { Object which = l.get(from++); if (equals(which, what)) result++; return result; |
Integer | count(List> values) Derives the number of values for the given list of values. if (values == null || values.size() == 0) { return 0; return values.size(); |
Map | count(List count Map<String, Integer> result = new HashMap<String, Integer>(); for (String line : lines) { if (line.toLowerCase().contains(DEBUG_KEY)) { Integer currentCount = (result.get(DEBUG_KEY) == null ? 0 : result.get(DEBUG_KEY)); result.put(DEBUG_KEY, currentCount + 1); } else if (line.toLowerCase().contains(INFO_KEY)) { Integer currentCount = (result.get(INFO_KEY) == null ? 0 : result.get(INFO_KEY)); result.put(INFO_KEY, currentCount + 1); ... |
int | countAtLevel(List aList, int aLevel) Returns the number of objects at a given level in the given list hierarchy. if (aLevel < 0) return 1; if (aLevel > 0) { int count = 0; for (int i = 0, iMax = aList.size(); i < iMax; i++) count += countAtLevel((List) aList.get(i), aLevel - 1); return count; return aList.size(); |
int | countNumber(List count Number int occurrences = Collections.frequency(list, number); return occurrences; |
int | countOccurances(List count Occurances int count = 0; for (int[] next : encodings) { if (contains(next, value)) { count++; return count; |
int | countOccurence(List count Occurence int count = 0; Iterator<Integer> iterValueList = valueList.iterator(); while (iterValueList.hasNext()) { int vaInList = iterValueList.next(); if (vaInList == value) { count++; return count; |
int | countOccurrencesOf(Object comparisonObject, List list) Return an integer representing the number of occurrences (using equals()) of the specified object in the specified list. int instances = 0; boolean comparisonObjectIsNull = comparisonObject == null; if (list != null) { for (int i = 0; i < list.size(); i++) { Object listObject = list.get(i); if ((comparisonObjectIsNull & listObject == null) || (!comparisonObjectIsNull && comparisonObject.equals(listObject))) { instances++; ... |