diff --git a/src/main/java/com/samskivert/util/CollectionUtil.java b/src/main/java/com/samskivert/util/CollectionUtil.java index ceae52f1..20b9f3a0 100644 --- a/src/main/java/com/samskivert/util/CollectionUtil.java +++ b/src/main/java/com/samskivert/util/CollectionUtil.java @@ -28,6 +28,7 @@ import java.util.Comparator; import java.util.Enumeration; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.NoSuchElementException; import com.samskivert.annotation.ReplacedBy; @@ -79,6 +80,30 @@ public class CollectionUtil return col; } + /** + * Folds all the specified values into the supplied collection and returns it. + */ + public static > C addAll ( + C col, Iterable> values) + { + for (Collection val : values) { + col.addAll(val); + } + return col; + } + + /** + * Folds all the specified values into the supplied map and returns it. + */ + public static > M putAll ( + M map, Iterable> values) + { + for (Map val : values) { + map.putAll(val); + } + return map; + } + /** * Modify the specified Collection so that only the first limit elements * remain, as determined by iteration order. If the Collection is smaller than limit,