-
Enhancement
-
Resolution: Duplicate
-
P5
-
None
-
6
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
Java Lists currently do not have a way of getting the count of a particular object within a List.
JUSTIFICATION :
I ran into this issue when I had a list of objects in which it contained some duplicates, and I needed to know the number of occurrences of specific objects within the list. Basically i built a list of referenced objects from a list of objects and needed the result of how many times a specific referenced object was in this built list, for later use.
I needed something like... myList.elementCount(obj);
where elementCount() returns int number of occurrences or -1 if it does not exist in the list, and obj is the assumed element in the list.
I was able to continue by creating a custom iterator, but the above alternative would have been a quicker solution.
Java Lists currently do not have a way of getting the count of a particular object within a List.
JUSTIFICATION :
I ran into this issue when I had a list of objects in which it contained some duplicates, and I needed to know the number of occurrences of specific objects within the list. Basically i built a list of referenced objects from a list of objects and needed the result of how many times a specific referenced object was in this built list, for later use.
I needed something like... myList.elementCount(obj);
where elementCount() returns int number of occurrences or -1 if it does not exist in the list, and obj is the assumed element in the list.
I was able to continue by creating a custom iterator, but the above alternative would have been a quicker solution.
- duplicates
-
JDK-4193200 Request for Collections.count method
- Resolved