How to intersect the data of two collections
/**
* Supports intersect two collections and return a single intersected collection
* @param a First collection parameter
* @param b Second collection parameter
* @return Intersected collection of results
*/
public static Collection intersect (Collection a, Collection b)
{
Collection result = new ArrayList ();
try {
for (T t: a){
if (b.remove (t)) {
result.add (t);
}
}
} catch (Exception e) {
return result;
}
return result;
}
* Supports intersect two collections and return a single intersected collection
* @param a First collection parameter
* @param b Second collection parameter
* @return Intersected collection of results
*/
public static
{
Collection
try {
for (T t: a){
if (b.remove (t)) {
result.add (t);
}
}
} catch (Exception e) {
return result;
}
return result;
}
Comments
Post a Comment