<dependency> <groupId>com.google.collections</groupId> <artifactId>google-collections</artifactId> <version>1.0</version> </dependency> List<String> list = Lists.newArrayList("A", "B", "C"); Set<String> set = Sets.newHashSet("A", "B", "C"); Map<String, Integer> map = Maps.newHashMap(); map.put("A", 1); map.put("B", 2); map.put("C", 3); Multimap<String, Integer> multimap = ArrayListMultimap.create(); multimap.put("A", 1); multimap.put("A", 2); multimap.put("B", 3); BiMap<String, Integer> biMap = HashBiMap.create(); biMap.put("A", 1); biMap.put("B", 2); Collection<Integer> filtered = Collections2.filter(collection, predicate); Collection<String> transformed = Collections2.transform(collection, function); Collection<List<String>> allCombinations = Collections2.orderedCombinations(list1, list2, ...); Iterable<Integer> filtered = Iterables.filter(iterable, predicate); List<String> transformed = Lists.newArrayList(Iterables.transform(iterable, function)); boolean anyMatch = Iterables.any(iterable, predicate); Iterator<Integer> filtered = Iterators.filter(iterator, predicate); String lastElement = Iterators.getLast(iterator); List<Integer> allElements = Lists.newArrayList(iterator);


上一篇:
下一篇:
切换中文