@ParametersAreNonnullByDefault
Package com.google.common.collect
This package contains generic collection interfaces and implementations, and
other utilities for working with collections. It is a part of the open-source
Guava libraries.
of
of
of
of
of
of
of
of
Collection Types
BiMap- An extension of
Mapthat guarantees the uniqueness of its values as well as that of its keys. This is sometimes called an "invertible map," since the restriction on values enables it to support an inverse view -- which is another instance ofBiMap. Multiset- An extension of
Collectionthat may contain duplicate values like aList, yet has order-independent equality like aSet. One typical use for a multiset is to represent a histogram. Multimap- A new type, which is similar to
Map, but may contain multiple entries with the same key. Some behaviors ofMultimapare left unspecified and are provided only by the subtypes mentioned below. ListMultimap- An extension of
Multimapwhich permits duplicate entries, supports random access of values for a particular key, and has partially order-dependent equality as defined byListMultimap.equals(Object).ListMultimaptakes its name from the fact that the collection of values associated with a given key fulfills theListcontract. SetMultimap- An extension of
Multimapwhich has order-independent equality and does not allow duplicate entries; that is, while a key may appear twice in aSetMultimap, each must map to a different value.SetMultimaptakes its name from the fact that the collection of values associated with a given key fulfills theSetcontract. SortedSetMultimap- An extension of
SetMultimapfor which the collection values associated with a given key is aSortedSet. Table- A new type, which is similar to
Map, but which indexes its values by an ordered pair of keys, a row key and column key. ClassToInstanceMap- An extension of
Mapthat associates a raw type with an instance of that type.
Collection Implementations
of List
of Set
ImmutableSetImmutableSortedSetContiguousSet(seeRange)
of Map
ImmutableMapImmutableSortedMapcom.google.common.collect.MapMaker
of BiMap
of Multiset
ImmutableMultisetHashMultisetLinkedHashMultisetTreeMultisetEnumMultisetcom.google.common.collect.ConcurrentHashMultiset
of Multimap
ImmutableMultimapImmutableListMultimapImmutableSetMultimapArrayListMultimapHashMultimapTreeMultimapLinkedHashMultimapLinkedListMultimap
of Table
of ClassToInstanceMap
Classes of static utility methods
Collections2IteratorsIterablesListsMapscom.google.common.collect.QueuesSetsMultisetsMultimapsTablesObjectArrays
Comparison
Abstract implementations
AbstractIteratorAbstractSequentialIteratorImmutableCollectionUnmodifiableIteratorUnmodifiableListIterator
Ranges
Other
Interner,com.google.common.collect.InternersConstraint,ConstraintsMapConstraint,MapConstraintsMapDifference,SortedMapDifferenceMinMaxPriorityQueuePeekingIterator
Forwarding collections
ForwardingCollectioncom.google.common.collect.ForwardingConcurrentMapForwardingIteratorForwardingListForwardingListIteratorForwardingListMultimapForwardingMapForwardingMapEntryForwardingMultimapForwardingMultisetForwardingNavigableMapForwardingNavigableSetForwardingObjectForwardingQueueForwardingSetForwardingSetMultimapForwardingSortedMapForwardingSortedMultisetForwardingSortedSetForwardingSortedSetMultimapForwardingTable
-
Interface Summary Interface Description BiMap<K,V> A bimap (or "bidirectional map") is a map that preserves the uniqueness of its values as well as that of its keys.ClassToInstanceMap<B> A map, each entry of which maps a Java raw type to an instance of that type.Interner<E> Provides equivalent behavior toString.intern()for other immutable types.ListMultimap<K,V> AMultimapthat can hold duplicate key-value pairs and that maintains the insertion ordering of values for a given key.MapConstraint<K,V> A constraint on the keys and values that may be added to aMaporMultimap.MapDifference<K,V> An object representing the differences between two maps.MapDifference.ValueDifference<V> A difference between the mappings from two maps with the same key.Maps.EntryTransformer<K,V1,V2> A transformation of the value of a key-value pair, using both key and value as inputs.Multimap<K,V> A collection that maps keys to values, similar toMap, but in which each key may be associated with multiple values.Multiset<E> A collection that supports order-independent equality, likeSet, but may have duplicate elements.Multiset.Entry<E> An unmodifiable element-count pair for a multiset.PeekingIterator<E> An iterator that supports a one-element lookahead while iterating.RangeMap<K extends java.lang.Comparable,V> A mapping from disjoint nonempty ranges to non-null values.RangeSet<C extends java.lang.Comparable> RowSortedTable<R,C,V> Interface that extendsTableand whose rows are sorted.SetMultimap<K,V> AMultimapthat cannot hold duplicate key-value pairs.SortedMapDifference<K,V> An object representing the differences between two sorted maps.SortedMultiset<E> AMultisetwhich maintains the ordering of its elements, according to either their natural order or an explicitComparator.SortedSetMultimap<K,V> ASetMultimapwhose set of values for a given key are kept sorted; that is, they comprise aSortedSet.Table<R,C,V> A collection that associates an ordered pair of keys, called a row key and a column key, with a single value.Table.Cell<R,C,V> Row key / column key / value triplet corresponding to a mapping in a table. -
Class Summary Class Description AbstractIterator<T> This class provides a skeletal implementation of theIteratorinterface, to make this interface easier to implement for certain types of data sources.AbstractSequentialIterator<T> This class provides a skeletal implementation of theIteratorinterface for sequences whose next element can always be derived from the previous element.ArrayListMultimap<K,V> Implementation ofMultimapthat uses anArrayListto store the values for a given key.ArrayTable<R,C,V> Fixed-sizeTableimplementation backed by a two-dimensional array.BinaryTreeTraverser<T> A variant ofTreeTraverserfor binary trees, providing additional traversals specific to binary trees.Collections2 Provides static methods for working withCollectioninstances.ComparisonChain A utility for performing a chained comparison statement.ContiguousSet<C extends java.lang.Comparable> A sorted set of contiguous values in a givenDiscreteDomain.DiscreteDomain<C extends java.lang.Comparable> A descriptor for a discreteComparabledomain such as allIntegerinstances.EnumBiMap<K extends java.lang.Enum<K>,V extends java.lang.Enum<V>> ABiMapbacked by twoEnumMapinstances.EnumHashBiMap<K extends java.lang.Enum<K>,V> ABiMapbacked by anEnumMapinstance for keys-to-values, and aHashMapinstance for values-to-keys.EnumMultiset<E extends java.lang.Enum<E>> Multiset implementation backed by anEnumMap.EvictingQueue<E> A non-blocking queue which automatically evicts elements from the head of the queue when attempting to add new elements onto the queue and it is full.FluentIterable<E> FluentIterableprovides a rich interface for manipulatingIterableinstances in a chained fashion.ForwardingCollection<E> A collection which forwards all its method calls to another collection.ForwardingDeque<E> A deque which forwards all its method calls to another deque.ForwardingIterator<T> An iterator which forwards all its method calls to another iterator.ForwardingList<E> A list which forwards all its method calls to another list.ForwardingListIterator<E> A list iterator which forwards all its method calls to another list iterator.ForwardingListMultimap<K,V> A list multimap which forwards all its method calls to another list multimap.ForwardingMap<K,V> A map which forwards all its method calls to another map.ForwardingMapEntry<K,V> A map entry which forwards all its method calls to another map entry.ForwardingMultimap<K,V> A multimap which forwards all its method calls to another multimap.ForwardingMultiset<E> A multiset which forwards all its method calls to another multiset.ForwardingNavigableMap<K,V> A navigable map which forwards all its method calls to another navigable map.ForwardingNavigableSet<E> A navigable set which forwards all its method calls to another navigable set.ForwardingObject An abstract base class for implementing the decorator pattern.ForwardingQueue<E> A queue which forwards all its method calls to another queue.ForwardingSet<E> A set which forwards all its method calls to another set.ForwardingSetMultimap<K,V> A set multimap which forwards all its method calls to another set multimap.ForwardingSortedMap<K,V> A sorted map which forwards all its method calls to another sorted map.ForwardingSortedMultiset<E> A sorted multiset which forwards all its method calls to another sorted multiset.ForwardingSortedSet<E> A sorted set which forwards all its method calls to another sorted set.ForwardingSortedSetMultimap<K,V> A sorted set multimap which forwards all its method calls to another sorted set multimap.ForwardingTable<R,C,V> A table which forwards all its method calls to another table.HashBasedTable<R,C,V> Implementation ofTableusing hash tables.HashBiMap<K,V> ABiMapbacked by two hash tables.HashMultimap<K,V> Implementation ofMultimapusing hash tables.HashMultiset<E> Multiset implementation backed by aHashMap.ImmutableBiMap<K,V> An immutableBiMapwith reliable user-specified iteration order.ImmutableBiMap.Builder<K,V> A builder for creating immutable bimap instances, especiallypublic static finalbimaps ("constant bimaps").ImmutableClassToInstanceMap<B> A class-to-instance map backed by anImmutableMap.ImmutableClassToInstanceMap.Builder<B> A builder for creating immutable class-to-instance maps.ImmutableCollection<E> An immutable collection.ImmutableCollection.Builder<E> Abstract base class for builders ofImmutableCollectiontypes.ImmutableList<E> A high-performance, immutable, random-accessListimplementation.ImmutableList.Builder<E> A builder for creating immutable list instances, especiallypublic static finallists ("constant lists").ImmutableListMultimap<K,V> An immutableListMultimapwith reliable user-specified key and value iteration order.ImmutableListMultimap.Builder<K,V> A builder for creating immutableListMultimapinstances, especiallypublic static finalmultimaps ("constant multimaps").ImmutableMap<K,V> An immutable, hash-basedMapwith reliable user-specified iteration order.ImmutableMap.Builder<K,V> A builder for creating immutable map instances, especiallypublic static finalmaps ("constant maps").ImmutableMultimap<K,V> An immutableMultimap.ImmutableMultimap.Builder<K,V> A builder for creating immutable multimap instances, especiallypublic static finalmultimaps ("constant multimaps").ImmutableMultiset<E> An immutable hash-based multiset.ImmutableMultiset.Builder<E> A builder for creating immutable multiset instances, especiallypublic static finalmultisets ("constant multisets").ImmutableRangeMap<K extends java.lang.Comparable<?>,V> An immutable implementation ofRangeMap, supporting all query operations efficiently.ImmutableRangeMap.Builder<K extends java.lang.Comparable<?>,V> A builder for immutable range maps.ImmutableRangeSet<C extends java.lang.Comparable> An efficient immutable implementation of aRangeSet.ImmutableRangeSet.Builder<C extends java.lang.Comparable<?>> A builder for immutable range sets.ImmutableSet<E> A high-performance, immutableSetwith reliable, user-specified iteration order.ImmutableSet.Builder<E> A builder for creating immutable set instances, especiallypublic static finalsets ("constant sets").ImmutableSetMultimap<K,V> An immutableSetMultimapwith reliable user-specified key and value iteration order.ImmutableSetMultimap.Builder<K,V> A builder for creating immutableSetMultimapinstances, especiallypublic static finalmultimaps ("constant multimaps").ImmutableSortedMap<K,V> An immutableSortedMap.ImmutableSortedMap.Builder<K,V> A builder for creating immutable sorted map instances, especiallypublic static finalmaps ("constant maps").ImmutableSortedMultiset<E> An immutableSortedMultisetthat stores its elements in a sorted array.ImmutableSortedMultiset.Builder<E> A builder for creating immutable multiset instances, especiallypublic static finalmultisets ("constant multisets").ImmutableSortedSet<E> An immutableSortedSetthat stores its elements in a sorted array.ImmutableSortedSet.Builder<E> A builder for creating immutable sorted set instances, especiallypublic static finalsets ("constant sets"), with a given comparator.ImmutableTable<R,C,V> An immutableTablewith reliable user-specified iteration order.ImmutableTable.Builder<R,C,V> A builder for creating immutable table instances, especiallypublic static finaltables ("constant tables").Iterables This class contains static utility methods that operate on or return objects of typeIterable.Iterators This class contains static utility methods that operate on or return objects of typeIterator.LinkedHashMultimap<K,V> Implementation ofMultimapthat does not allow duplicate key-value entries and that returns collections whose iterators follow the ordering in which the data was added to the multimap.LinkedHashMultiset<E> AMultisetimplementation with predictable iteration order.LinkedListMultimap<K,V> An implementation ofListMultimapthat supports deterministic iteration order for both keys and values.Lists Static utility methods pertaining toListinstances.MapConstraints Factory and utilities pertaining to theMapConstraintinterface.Maps MinMaxPriorityQueue<E> A double-ended priority queue, which provides constant-time access to both its least element and its greatest element, as determined by the queue's specified comparator.MinMaxPriorityQueue.Builder<B> The builder class used in creation of min-max priority queues.MultimapBuilder<K0,V0> A builder for a multimap implementation that allows customization of the backing map and value collection implementations used in a particular multimap.MultimapBuilder.ListMultimapBuilder<K0,V0> A specialization ofMultimapBuilderthat generatesListMultimapinstances.MultimapBuilder.MultimapBuilderWithKeys<K0> An intermediate stage in aMultimapBuilderin which the key-value collection map implementation has been specified, but the value collection implementation has not.MultimapBuilder.SetMultimapBuilder<K0,V0> A specialization ofMultimapBuilderthat generatesSetMultimapinstances.MultimapBuilder.SortedSetMultimapBuilder<K0,V0> A specialization ofMultimapBuilderthat generatesSortedSetMultimapinstances.Multimaps Provides static methods acting on or generating aMultimap.Multisets Provides static utility methods for creating and working withMultisetinstances.MutableClassToInstanceMap<B> A mutable class-to-instance map backed by an arbitrary user-provided map.ObjectArrays Static utility methods pertaining to object arrays.Ordering<T> A comparator, with additional methods to support common operations.Range<C extends java.lang.Comparable> A range (or "interval") defines the boundaries around a contiguous span of values of someComparabletype; for example, "integers from 1 to 100 inclusive." Note that it is not possible to iterate over these contained values.Sets Static utility methods pertaining toSetinstances.Sets.SetView<E> An unmodifiable view of a set which may be backed by other sets; this view will change as the backing sets do.Tables Provides static methods that involve aTable.TreeBasedTable<R,C,V> Implementation ofTablewhose row keys and column keys are ordered by their natural ordering or by supplied comparators.TreeMultimap<K,V> Implementation ofMultimapwhose keys and values are ordered by their natural ordering or by supplied comparators.TreeMultiset<E> A multiset which maintains the ordering of its elements, according to either their natural order or an explicitComparator.TreeRangeMap<K extends java.lang.Comparable,V> An implementation ofRangeMapbased on aTreeMap, supporting all optional operations.TreeRangeSet<C extends java.lang.Comparable<?>> An implementation ofRangeSetbacked by aTreeMap.TreeTraverser<T> Views elements of a typeTas nodes in a tree, and provides methods to traverse the trees induced by this traverser.UnmodifiableIterator<E> An iterator that does not supportUnmodifiableIterator.remove().UnmodifiableListIterator<E> A list iterator that does not supportUnmodifiableIterator.remove(),UnmodifiableListIterator.add(E), orUnmodifiableListIterator.set(E). -
Enum Summary Enum Description BoundType Indicates whether an endpoint of some range is contained in the range itself ("closed") or not ("open"). -
Exception Summary Exception Description ComputationException Wraps an exception that occurred during a computation.