Went ahead and did the complicated thing, it's good exercise.

Definitely does not pass the "less code is better code" test.
:(


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@827 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2009-05-27 17:43:19 +00:00
parent 16413e83fa
commit 2b368d173e
@@ -32,6 +32,7 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
@@ -226,12 +227,19 @@ public class BundledComponentRepository
// documentation inherited
public Iterator<Integer> enumerateComponentIds (final ComponentClass compClass)
{
return Iterators.filter(_components.keySet().iterator(), new Predicate<Integer>() {
public boolean apply (Integer input) {
CharacterComponent comp = _components.get(input);
return comp.componentClass.equals(compClass);
}
});
Predicate<Map.Entry<Integer,CharacterComponent>> pred =
new Predicate<Map.Entry<Integer,CharacterComponent>>() {
public boolean apply (Map.Entry<Integer,CharacterComponent> entry) {
return entry.getValue().componentClass.equals(compClass);
}
};
Function<Map.Entry<Integer,CharacterComponent>,Integer> func =
new Function<Map.Entry<Integer,CharacterComponent>,Integer>() {
public Integer apply (Map.Entry<Integer,CharacterComponent> entry) {
return entry.getKey();
}
};
return Iterators.transform(Iterators.filter(_components.entrySet().iterator(), pred), func);
}
/**