It looks like what you might want to do first is to index the cars in your list by speed. Once you do this, it may be easier to complete all the remaining processing that you are looking for. Guava multimap are good for this
ImmutableListMultimap<Integer, Car> speedIndex = Multimaps.index(cars, new Function<Car, Integer>() { public Integer apply(Car from) { return from.getSpeed(); } });
speedIndex will now be a speedIndex , allowing you to do something like this:
for (Integer speed : speedIndex.keySet()) { ImmutableList<Car> carsWithSpeed = speedIndex.get(speed);
This gives you groupings of all cars in the original list that have the same speed. You could do whatever processing you like. You may want to index this group of cars by model, giving you groups of cars that have the same speeds and models. You could remove these cars from the original list if you want. Alternatively, if you do not want to change the original list at all, but just get a copy of the list with the deleted set of cars, you can add each car to be deleted in Set , and then get a copy with these cars removed as follows:
Set<Car> carsToRemove = ...; List<Car> filteredList = Lists.newArrayList(Iterables.filter(cars, Predicates.not(Predicates.in(carsToRemove))));
source share