Top Description Inners Fields Constructors Methods
com.google.common.collect

public Class ImmutableRangeMap<K extends java.lang.Comparable<?>, V>

extends Object
implements RangeMap<K extends Comparable<?>, V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.google.common.collect.RangeMap
Annotations
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkElementIndex, .Preconditions.checkNotNull

A RangeMap whose contents will never change, with many other important properties detailed at ImmutableCollection.
Author
Louis Wasserman
Since
14.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ImmutableRangeMap.Builder<K extends Comparable<?>, V>

A builder for immutable range maps.

private static class
ImmutableRangeMap.SerializedForm<K extends Comparable<?>, V>

This class is used to serialize ImmutableRangeMap instances.

Field Summary

Modifier and TypeField and Description
private static final ImmutableRangeMap<Comparable<?>, Object>
private final transient ImmutableList<Range<K>>
private static final long
private final transient ImmutableList<V>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ImmutableMap<Range<K>, V>
asDescendingMapOfRanges()

Implements com.google.common.collect.RangeMap.asDescendingMapOfRanges.

Returns a view of this range map as an unmodifiable Map<Range<K>, V>.
public ImmutableMap<Range<K>, V>
asMapOfRanges()

Implements com.google.common.collect.RangeMap.asMapOfRanges.

Returns a view of this range map as an unmodifiable Map<Range<K>, V>.
public static <K extends Comparable<?>, V> ImmutableRangeMap.Builder<K, V>
builder()

Returns a new builder for an immutable range map.

public final void
clear()

Implements com.google.common.collect.RangeMap.clear.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the RangeMap unmodified.
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V>
copyOf(RangeMap<K, ? extends V> rangeMap)

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Implements com.google.common.collect.RangeMap.equals.

Returns true if obj is another RangeMap that has an equivalent asMapOfRanges().
public V
get(K key)

Implements com.google.common.collect.RangeMap.get.

Returns the value associated with the specified key, or null if there is no such value.
public Map.Entry<Range<K>, V>
getEntry(K key)

Implements com.google.common.collect.RangeMap.getEntry.

Returns the range containing this key and its associated value, if such a range is present in the range map, or null otherwise.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements com.google.common.collect.RangeMap.hashCode.

Returns asMapOfRanges().hashCode().
public final void
merge(Range<K> range, V value, BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction)

Implements com.google.common.collect.RangeMap.merge.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the RangeMap unmodified.
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V>
of()

Returns an empty immutable range map.

public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V>
of(Range<K> range, V value)

Returns an immutable range map mapping a single range to a single value.

public final void
put(Range<K> range, V value)

Implements com.google.common.collect.RangeMap.put.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the RangeMap unmodified.
public final void
putAll(RangeMap<K, ? extends V> rangeMap)

Implements com.google.common.collect.RangeMap.putAll.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the RangeMap unmodified.
public final void
putCoalescing(Range<K> range, V value)

Implements com.google.common.collect.RangeMap.putCoalescing.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the RangeMap unmodified.
private void
public final void
remove(Range<K> range)

Implements com.google.common.collect.RangeMap.remove.

Deprecated Unsupported operation.
Guaranteed to throw an exception and leave the RangeMap unmodified.
public Range<K>
span()

Implements com.google.common.collect.RangeMap.span.

Returns the minimal range enclosing the ranges in this RangeMap.
public ImmutableRangeMap<K, V>
subRangeMap(final Range<K> range)

Implements com.google.common.collect.RangeMap.subRangeMap.

Returns a view of the part of this range map that intersects with range.
public static <T extends @Nullable Object, K extends Comparable<? super K>, V> Collector<T, ?, ImmutableRangeMap<K, V>>
toImmutableRangeMap(Function<? super T, Range<K>> keyFunction, Function<? super T, ? extends V> valueFunction)

Returns a Collector that accumulates the input elements into a new ImmutableRangeMap.

public String
toString()

Overrides java.lang.Object.toString.

Implements com.google.common.collect.RangeMap.toString.

Returns a readable string representation of this range map.
pack-priv Object
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

EMPTYback to summary
private static final ImmutableRangeMap<Comparable<?>, Object> EMPTY
rangesback to summary
private final transient ImmutableList<Range<K>> ranges
serialVersionUIDback to summary
private static final long serialVersionUID
valuesback to summary
private final transient ImmutableList<V> values

Constructor Detail

ImmutableRangeMapback to summary
pack-priv ImmutableRangeMap(ImmutableList<Range<K>> ranges, ImmutableList<V> values)

Method Detail

asDescendingMapOfRangesback to summary
public ImmutableMap<Range<K>, V> asDescendingMapOfRanges()

Implements com.google.common.collect.RangeMap.asDescendingMapOfRanges.

Doc from com.google.common.collect.RangeMap.asDescendingMapOfRanges.

Returns a view of this range map as an unmodifiable Map<Range<K>, V>. Modifications to this range map are guaranteed to read through to the returned Map.

The returned Map iterates over entries in descending order of the bounds of the Range entries.

It is guaranteed that no empty ranges will be in the returned Map.

Annotations
@Override
asMapOfRangesback to summary
public ImmutableMap<Range<K>, V> asMapOfRanges()

Implements com.google.common.collect.RangeMap.asMapOfRanges.

Doc from com.google.common.collect.RangeMap.asMapOfRanges.

Returns a view of this range map as an unmodifiable Map<Range<K>, V>. Modifications to this range map are guaranteed to read through to the returned Map.

The returned Map iterates over entries in ascending order of the bounds of the Range entries.

It is guaranteed that no empty ranges will be in the returned Map.

Annotations
@Override
builderback to summary
public static <K extends Comparable<?>, V> ImmutableRangeMap.Builder<K, V> builder()

Returns a new builder for an immutable range map.

clearback to summary
public final void clear()

Implements com.google.common.collect.RangeMap.clear.

Deprecated

Unsupported operation.

Guaranteed to throw an exception and leave the RangeMap unmodified.

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
copyOfback to summary
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> copyOf(RangeMap<K, ? extends V> rangeMap)
Annotations
@SuppressWarnings:unchecked
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements com.google.common.collect.RangeMap.equals.

Doc from com.google.common.collect.RangeMap.equals.

Returns true if obj is another RangeMap that has an equivalent asMapOfRanges().

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getback to summary
public V get(K key)

Implements com.google.common.collect.RangeMap.get.

Doc from com.google.common.collect.RangeMap.get.

Returns the value associated with the specified key, or null if there is no such value.

Specifically, if any range in this range map contains the specified key, the value associated with that range is returned.

Annotations
@Override
@CheckForNull
getEntryback to summary
public Map.Entry<Range<K>, V> getEntry(K key)

Implements com.google.common.collect.RangeMap.getEntry.

Doc from com.google.common.collect.RangeMap.getEntry.

Returns the range containing this key and its associated value, if such a range is present in the range map, or null otherwise.

Annotations
@Override
@CheckForNull
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements com.google.common.collect.RangeMap.hashCode.

Doc from com.google.common.collect.RangeMap.hashCode.

Returns asMapOfRanges().hashCode().

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
mergeback to summary
public final void merge(Range<K> range, V value, BiFunction<? super V, ? super @Nullable V, ? extends @Nullable V> remappingFunction)

Implements com.google.common.collect.RangeMap.merge.

Deprecated

Unsupported operation.

Guaranteed to throw an exception and leave the RangeMap unmodified.

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
ofback to summary
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> of()

Returns an empty immutable range map.

Performance note: the instance returned is a singleton.

Annotations
@SuppressWarnings:unchecked
ofback to summary
public static <K extends Comparable<?>, V> ImmutableRangeMap<K, V> of(Range<K> range, V value)

Returns an immutable range map mapping a single range to a single value.

putback to summary
public final void put(Range<K> range, V value)

Implements com.google.common.collect.RangeMap.put.

Deprecated

Unsupported operation.

Guaranteed to throw an exception and leave the RangeMap unmodified.

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
putAllback to summary
public final void putAll(RangeMap<K, ? extends V> rangeMap)

Implements com.google.common.collect.RangeMap.putAll.

Deprecated

Unsupported operation.

Guaranteed to throw an exception and leave the RangeMap unmodified.

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
putCoalescingback to summary
public final void putCoalescing(Range<K> range, V value)

Implements com.google.common.collect.RangeMap.putCoalescing.

Deprecated

Unsupported operation.

Guaranteed to throw an exception and leave the RangeMap unmodified.

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
readObjectback to summary
private void readObject(ObjectInputStream stream) throws InvalidObjectException
Annotations
@J2ktIncompatible
removeback to summary
public final void remove(Range<K> range)

Implements com.google.common.collect.RangeMap.remove.

Deprecated

Unsupported operation.

Guaranteed to throw an exception and leave the RangeMap unmodified.

Annotations
@Deprecated
@Override
@DoNotCall:Always throws UnsupportedOperationException
Exceptions
UnsupportedOperationException:
always
spanback to summary
public Range<K> span()

Implements com.google.common.collect.RangeMap.span.

Doc from com.google.common.collect.RangeMap.span.

Returns the minimal range enclosing the ranges in this RangeMap.

Annotations
@Override
subRangeMapback to summary
public ImmutableRangeMap<K, V> subRangeMap(final Range<K> range)

Implements com.google.common.collect.RangeMap.subRangeMap.

Doc from com.google.common.collect.RangeMap.subRangeMap.

Returns a view of the part of this range map that intersects with range.

For example, if rangeMap had the entries [1, 5] => "foo", (6, 8) => "bar", (10, ∞) => "baz" then rangeMap.subRangeMap(Range.open(3, 12)) would return a range map with the entries (3, 5] => "foo", (6, 8) => "bar", (10, 12) => "baz".

The returned range map supports all optional operations that this range map supports, except for asMapOfRanges().iterator().remove().

The returned range map will throw an IllegalArgumentException on an attempt to insert a range not enclosed by range.

Annotations
@Override
toImmutableRangeMapback to summary
public static <T extends @Nullable Object, K extends Comparable<? super K>, V> Collector<T, ?, ImmutableRangeMap<K, V>> toImmutableRangeMap(Function<? super T, Range<K>> keyFunction, Function<? super T, ? extends V> valueFunction)

Returns a Collector that accumulates the input elements into a new ImmutableRangeMap. As in Builder, overlapping ranges are not permitted.

Since
23.1
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements com.google.common.collect.RangeMap.toString.

Doc from com.google.common.collect.RangeMap.toString.

Returns a readable string representation of this range map.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()
com.google.common.collect back to summary

public final Class ImmutableRangeMap.Builder<K extends java.lang.Comparable<?>, V>

extends Object
Class Inheritance
Annotations
@DoNotMock

A builder for immutable range maps. Overlapping ranges are prohibited.
Since
14.0

Field Summary

Modifier and TypeField and Description
private final List<Map.Entry<Range<K>, V>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ImmutableRangeMap<K, V>
build()

Returns an ImmutableRangeMap containing the associations previously added to this builder.

pack-priv ImmutableRangeMap.Builder<K, V>
public ImmutableRangeMap.Builder<K, V>
put(Range<K> range, V value)

Associates the specified range with the specified value.

public ImmutableRangeMap.Builder<K, V>
putAll(RangeMap<K, ? extends V> rangeMap)

Copies all associations from the specified range map into this builder.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final List<Map.Entry<Range<K>, V>> entries

Constructor Detail

Builderback to summary
public Builder()

Method Detail

buildback to summary
public ImmutableRangeMap<K, V> build()

Returns an ImmutableRangeMap containing the associations previously added to this builder.

Exceptions
IllegalArgumentException:
if any two ranges inserted into this builder overlap
combineback to summary
pack-priv ImmutableRangeMap.Builder<K, V> combine(ImmutableRangeMap.Builder<K, V> builder)
Annotations
@CanIgnoreReturnValue
putback to summary
public ImmutableRangeMap.Builder<K, V> put(Range<K> range, V value)

Associates the specified range with the specified value.

Annotations
@CanIgnoreReturnValue
Exceptions
IllegalArgumentException:
if range is empty
putAllback to summary
public ImmutableRangeMap.Builder<K, V> putAll(RangeMap<K, ? extends V> rangeMap)

Copies all associations from the specified range map into this builder.

Annotations
@CanIgnoreReturnValue
com.google.common.collect back to summary

private Class ImmutableRangeMap.SerializedForm<K extends java.lang.Comparable<?>, V>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

This class is used to serialize ImmutableRangeMap instances. Serializes the asMapOfRanges() form.

Field Summary

Modifier and TypeField and Description
private final ImmutableMap<Range<K>, V>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
SerializedForm(ImmutableMap<Range<K>, V> mapOfRanges)

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapOfRangesback to summary
private final ImmutableMap<Range<K>, V> mapOfRanges
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SerializedFormback to summary
pack-priv SerializedForm(ImmutableMap<Range<K>, V> mapOfRanges)

Method Detail

createRangeMapback to summary
pack-priv Object createRangeMap()
readResolveback to summary
pack-priv Object readResolve()