Compartir a través de


ISortedMap Interface

Definition

A Map that further provides a <em>total ordering</em> on its keys.

[Android.Runtime.Register("java/util/SortedMap", "", "Java.Util.ISortedMapInvoker")]
[Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })]
public interface ISortedMap : IDisposable, Java.Interop.IJavaPeerable, Java.Util.IMap
[<Android.Runtime.Register("java/util/SortedMap", "", "Java.Util.ISortedMapInvoker")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })>]
type ISortedMap = interface
    interface IMap
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Derived
Attributes
Implements

Remarks

A Map that further provides a <em>total ordering</em> on its keys. The map is ordered according to the Comparable natural ordering of its keys, or by a Comparator typically provided at sorted map creation time. This order is reflected when iterating over the sorted map's collection views (returned by the entrySet, keySet and values methods). Several additional operations are provided to take advantage of the ordering. (This interface is the map analogue of SortedSet.)

All keys inserted into a sorted map must implement the Comparable interface (or be accepted by the specified comparator). Furthermore, all such keys must be <em>mutually comparable</em>: k1.compareTo(k2) (or comparator.compare(k1, k2)) must not throw a ClassCastException for any keys k1 and k2 in the sorted map. Attempts to violate this restriction will cause the offending method or constructor invocation to throw a ClassCastException.

Note that the ordering maintained by a sorted map (whether or not an explicit comparator is provided) must be <em>consistent with equals</em> if the sorted map is to correctly implement the Map interface. (See the Comparable interface or Comparator interface for a precise definition of <em>consistent with equals</em>.) This is so because the Map interface is defined in terms of the equals operation, but a sorted map performs all key comparisons using its compareTo (or compare) method, so two keys that are deemed equal by this method are, from the standpoint of the sorted map, equal. The behavior of a tree map <em>is</em> well-defined even if its ordering is inconsistent with equals; it just fails to obey the general contract of the Map interface.

All general-purpose sorted map implementation classes should provide four "standard" constructors. It is not possible to enforce this recommendation though as required constructors cannot be specified by interfaces. The expected "standard" constructors for all sorted map implementations are: <ol> <li>A void (no arguments) constructor, which creates an empty sorted map sorted according to the natural ordering of its keys.</li> <li>A constructor with a single argument of type Comparator, which creates an empty sorted map sorted according to the specified comparator.</li> <li>A constructor with a single argument of type Map, which creates a new map with the same key-value mappings as its argument, sorted according to the keys' natural ordering.</li> <li>A constructor with a single argument of type SortedMap, which creates a new sorted map with the same key-value mappings and the same ordering as the input sorted map.</li> </ol>

<strong>Note</strong>: several methods return submaps with restricted key ranges. Such ranges are <em>half-open</em>, that is, they include their low endpoint but not their high endpoint (where applicable). If you need a <em>closed range</em> (which includes both endpoints), and the key type allows for calculation of the successor of a given key, merely request the subrange from lowEndpoint to successor(highEndpoint). For example, suppose that m is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are between low and high, inclusive:

SortedMap&lt;String, V&gt; sub = m.subMap(low, high+"\0");

A similar technique can be used to generate an <em>open range</em> (which contains neither endpoint). The following idiom obtains a view containing all of the key-value mappings in m whose keys are between low and high, exclusive:

SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);

This interface is a member of the Java Collections Framework.

Added in 1.2.

Java documentation for java.util.SortedMap.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
IsEmpty

Returns whether this map is empty.

(Inherited from IMap)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

Clear()

Removes all of the mappings from this map (optional operation).

(Inherited from IMap)
Comparator()

Returns the comparator used to order the keys in this map, or null if this map uses the Comparable natural ordering of its keys.

Compute(Object, IBiFunction)

Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).

(Inherited from IMap)
ComputeIfAbsent(Object, IFunction)

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

(Inherited from IMap)
ComputeIfPresent(Object, IBiFunction)

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.

(Inherited from IMap)
ContainsKey(Object)

Returns true if this map contains a mapping for the specified key.

(Inherited from IMap)
ContainsValue(Object)

Returns true if this map maps one or more keys to the specified value.

(Inherited from IMap)
Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
EntrySet()

Returns a Set view of the mappings contained in this map.

Equals(Object)

Compares the specified object with this map for equality.

(Inherited from IMap)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
FirstKey()

Returns the first (lowest) key currently in this map.

ForEach(IBiConsumer)

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.

(Inherited from IMap)
Get(Object)

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

(Inherited from IMap)
GetHashCode()

Returns the hash code value for this map.

(Inherited from IMap)
GetOrDefault(Object, Object)

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

(Inherited from IMap)
HeadMap(Object)

Returns a view of the portion of this map whose keys are strictly less than toKey.

KeySet()

Returns a Set view of the keys contained in this map.

LastKey()

Returns the last (highest) key currently in this map.

Merge(Object, Object, IBiFunction)

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value.

(Inherited from IMap)
Put(Object, Object)

Associates the specified value with the specified key in this map (optional operation).

(Inherited from IMap)
PutAll(IDictionary)

Copies all of the mappings from the specified map to this map (optional operation).

(Inherited from IMap)
PutIfAbsent(Object, Object)

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value.

(Inherited from IMap)
Remove(Object, Object)

Removes the entry for the specified key only if it is currently mapped to the specified value.

(Inherited from IMap)
Remove(Object)

Removes the mapping for a key from this map if it is present (optional operation).

(Inherited from IMap)
Replace(Object, Object, Object)

Replaces the entry for the specified key only if currently mapped to the specified value.

(Inherited from IMap)
Replace(Object, Object)

Replaces the entry for the specified key only if it is currently mapped to some value.

(Inherited from IMap)
ReplaceAll(IBiFunction)

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.

(Inherited from IMap)
SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
Size()

Returns the number of key-value mappings in this map.

(Inherited from IMap)
SubMap(Object, Object)

Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.

TailMap(Object)

Returns a view of the portion of this map whose keys are greater than or equal to fromKey.

UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)
Values()

Returns a Collection view of the values contained in this map.

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to