| Modifier and Type | Field and Description |
|---|---|
| private K | |
| private K | |
| private static final long | |
| private V | |
| private V |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv |
| key1 | back to summary |
|---|---|
| private K key1 | |
| key2 | back to summary |
|---|---|
| private K key2 | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| value1 | back to summary |
|---|---|
| private V value1 | |
| value2 | back to summary |
|---|---|
| private V value2 | |
| DoubletonMap | back to summary |
|---|---|
public DoubletonMap()
| |
| DoubletonMap | back to summary |
|---|---|
| pack-priv DoubletonMap(K key1, V value1, K key2, V value2) | |
| clone | back to summary |
|---|---|
| public DoubletonMap Implements abstract org. Implements org. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| collect | back to summary |
|---|---|
| public <K2, V2> FixedSizeMap Implements abstract org. Implements org. Doc from org. For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.
MapIterable<String, String> collected =
peopleByCity.collect((City city, Person person) -> Pair.of(city.getCountry(), person.getAddress().getCity()));
| |
| collectKeysUnique | back to summary |
|---|---|
| public <R> FixedSizeMap Implements abstract org. Implements org. Doc from org. For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the keys projected from the function rather than the original keys.
| |
| collectValues | back to summary |
|---|---|
| public <R> FixedSizeMap Implements abstract org. Implements org. Doc from org. For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.
MapIterable<City, String> collected =
peopleByCity.collectValues((City city, Person person) -> person.getFirstName() + " " + person.getLastName());
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Implements org. Doc from java. Returns
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Implements org. Doc from java. Returns
| |
| detect | back to summary |
|---|---|
| public Pair Overrides org. Implements org. Doc from org. Return the first key and value of the map for which the predicate evaluates to true when they are given as arguments. The predicate will only be evaluated until such pair is found or until all the keys and values of the map have been used as arguments. That is, there may be keys and values of the map that are never used as arguments to the predicate. The result is null if predicate does not evaluate to true for any key/value combination.
Pair<City, Person> detected =
peopleByCity.detect((City city, Person person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| entrySet | back to summary |
|---|---|
| public MutableSet Implements java. Doc from java. Returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Implements org. Doc from org. Follows the same general contract as
| |
| filter | back to summary |
|---|---|
| private FixedSizeMap | |
| flipUniqueValues | back to summary |
|---|---|
| public MutableMap Overrides org. Implements org. Doc from org. Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key.
MapIterable<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
MapIterable<String, Integer> result = map.flipUniqueValues();
Assert.assertTrue(result.equals(UnifiedMap.newWithKeysValues("1", 1, "2", 2, "3", 3)));
| |
| forEachKey | back to summary |
|---|---|
| public void forEachKey(Procedure<? super K> procedure) Overrides org. Implements org. Doc from org. Calls the
final Collection<Integer> result = new ArrayList<Integer>();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
map.forEachKey(new CollectionAddProcedure<Integer>(result));
Verify.assertContainsAll(result, 1, 2, 3);
| |
| forEachKeyValue | back to summary |
|---|---|
| public void forEachKeyValue(Procedure2<? super K, ? super V> procedure) Implements org. Doc from org. Calls the
final Collection<String> collection = new ArrayList<String>();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value));
Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
| |
| forEachValue | back to summary |
|---|---|
| public void forEachValue(Procedure<? super V> procedure) Overrides org. Implements org. Doc from org. Calls the procedure with each value of the map.
Set<String> result = UnifiedSet.newSet();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three", 4, "Four");
map.forEachValue(new CollectionAddProcedure<String>(result));
Verify.assertSetsEqual(UnifiedSet.newSetWith("One", "Two", "Three", "Four"), result);
| |
| forEachWith | back to summary |
|---|---|
| public <P> void forEachWith(Procedure2<? super V, ? super P> procedure, P parameter) Overrides org. Implements org. Doc from org. The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument. Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) ->
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}, fred);
Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>()
{
public void value(Person person, Person other)
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}
}, fred);
| |
| forEachWithIndex | back to summary |
|---|---|
| public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) Overrides org. Implements org. Doc from org. Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>()
{
public void value(Person person, int index)
{
LOGGER.info("Index: " + index + " person: " + person.getName());
}
});
| |
| get | back to summary |
|---|---|
| public V get(Object key) Implements org. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| getKey1 | back to summary |
|---|---|
| pack-priv K getKey1() | |
| getKey2 | back to summary |
|---|---|
| pack-priv K getKey2() | |
| getOnly | back to summary |
|---|---|
| public V getOnly() Overrides org. Overrides default org. Doc from org. Returns the element if the iterable has exactly one element. Otherwise, throw
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from org. Follows the same general contract as
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a
| |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| reject | back to summary |
|---|---|
| public FixedSizeMap Implements abstract org. Implements org. Doc from org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map.
MapIterable<City, Person> rejected =
peopleByCity.reject((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| select | back to summary |
|---|---|
| public FixedSizeMap Implements abstract org. Implements org. Doc from org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map.
MapIterable<City, Person> selected =
peopleByCity.select((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| toImmutable | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org. Doc from org. Returns an immutable copy of this map. If the map is immutable, it returns itself.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Implements org. Doc from org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. Each key and value is separated by an equals sign.
Assert.assertEquals("{1=1, 2=2, 3=3}", Maps.mutable.with(1, 1, 2, 2, 3, 3).toString());
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Doc from java. Returns a
| |
| withKeyValue | back to summary |
|---|---|
| public MutableMap Overrides org. Implements org. Doc from org. This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original plus the additional key and value. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:
map = map.withKeyValue("new key", "new value");
In the case of FixedSizeMap, a new instance will be returned by withKeyValue, and any variables that
previously referenced the original map will need to be redirected to reference the new instance. In the case
of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap
will both return "this" after calling put on themselves.
| |
| withoutKey | back to summary |
|---|---|
| public MutableMap Overrides org. Implements org. Doc from org. This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original minus the key and value to be removed. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:
map = map.withoutKey("key");
In the case of FixedSizeMap, a new instance will be returned by withoutKey, and any variables that previously
referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap
or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return
"this" after calling remove on themselves.
| |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |