commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roman Rytov" <rry...@entopia.com>
Subject [Collection] Is there a way to branch (group) a collection?
Date Sun, 10 Nov 2002 18:41:19 GMT
Assume a collection of objects exists and there is an object
implementing Predicate interface. Also let's say that evaluate(Object
obj) method returns a number of distinct objects (out of this
collection) and the number is noticeably less than total amount of
objects in the collection. Is there a way to get all collections grouped
by the predicator? An example may be schematically written like:
 
class Man {
String name;
int age;
}
 
class AgePredicator implements Predicate {
    int age;
    boolean evaluate (Object obj) {
Man man = (Man)obj;
return man.age == this.age;
}
 
 
collection men = { ('Isac', 35), ('Jerry', 32), ('Gonsales', 35),
('Moshe' , 22), ('Hans', 32), ('Mussa', 32)}
 
afer grouping it's supposed to get 3 collections:
 
('Isac', 35), ('Gonsales', 35), 
('Jerry', 32), ('Hans', 32), ('Mussa', 32)}
('Moshe' , 22), 
 
 
Do we have something in the API do achieve it easily?
 
 
_______________________
Roman Rytov


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message