Change-Id: I06affe3386f014ae098c31416503fd941f3c7d36
"""
index :: [(a,b)] -> a -> Maybe b
+ """
+ Given a list of elements, the function produces its characteristic function.
+ """
+ indexSet :: [a] -> a -> Boolean
+
"""
Given a list of values and a function computing a key for each value, the function produces a function that finds a value
effeciently for the given key.
}
};
}
-
+
+ public static Function indexSet(List<Object> l) {
+ THashSet set = new THashSet(l.size());
+ for(Object obj : l)
+ set.add(obj);
+ return new FunctionImpl1<Object,Object>() {
+ @Override
+ public Object apply(Object p0) {
+ return set.contains(p0);
+ }
+ };
+ }
+
public static Function indexBy(Function f, List l) {
THashMap map = new THashMap(l.size());
for(Object o : l)