ArrayMap Class

Definition

ArrayMap is a generic key->value mapping data structure that is designed to be more memory efficient than a traditional java.util.HashMap.

[Android.Runtime.Register("android/util/ArrayMap", DoNotGenerateAcw=true)]
[Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })]
public sealed class ArrayMap : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.Util.IMap
[<Android.Runtime.Register("android/util/ArrayMap", DoNotGenerateAcw=true)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "K", "V" })>]
type ArrayMap = class
    inherit Object
    interface IMap
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
ArrayMap
Attributes
Implements

Remarks

ArrayMap is a generic key->value mapping data structure that is designed to be more memory efficient than a traditional java.util.HashMap. It keeps its mappings in an array data structure -- an integer array of hash codes for each item, and an Object array of the key/value pairs. This allows it to avoid having to create an extra object for every entry put in to the map, and it also tries to control the growth of the size of these arrays more aggressively (since growing them only requires copying the entries in the array, not rebuilding a hash map).

Note that this implementation is not intended to be appropriate for data structures that may contain large numbers of items. It is generally slower than a traditional HashMap, since lookups require a binary search and adds and removes require inserting and deleting entries in the array. For containers holding up to hundreds of items, the performance difference is not significant, less than 50%.

Because this container is intended to better balance memory use, unlike most other standard Java containers it will shrink its array as items are removed from it. Currently you have no control over this shrinking -- if you set a capacity and then remove an item, it may reduce the capacity to better match the current size. In the future an explicit call to set the capacity should turn off this aggressive shrinking behavior.

This structure is <b>NOT</b> thread-safe.

Java documentation for android.util.ArrayMap.

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.

Constructors

Name Description
ArrayMap()

Create a new empty ArrayMap.

ArrayMap(ArrayMap)

Create a new ArrayMap with the mappings from the given ArrayMap.

ArrayMap(Int32)

Create a new ArrayMap with a given initial capacity.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsEmpty

Return true if the array map contains no items.

JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniPeerMembers
PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Name Description
Clear()

Make the array map empty.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
ContainsAll(ICollection<Object>)

Determine if the array map contains all of the keys in the given collection.

ContainsKey(Object)

Check whether a key exists in the array.

ContainsValue(Object)

Check whether a value exists in the array.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
EnsureCapacity(Int32)

Ensure the array map can hold at least <var>minimumCapacity</var> items.

EntrySet()

Return a java.util.Set for iterating over and interacting with all mappings in the array map.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
ForEach(IBiConsumer)

Performs the given action for all elements in the stored order.

Get(Object)

Retrieve a value from the array.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
IndexOfKey(Object)

Returns the index of a key in the set.

IndexOfValue(Object)

Returns an index for which #valueAt would return the specified value, or a negative number if no keys map to the specified value.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
KeyAt(Int32)

Return the key at the given index in the array.

KeySet()

Return a java.util.Set for iterating over and interacting with all keys in the array map.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Put(Object, Object)

Add a new value to the array map.

PutAll(ArrayMap)

Perform a #put(Object, Object) of all key/value pairs in <var>array</var>

PutAll(IDictionary)

Perform a #put(Object, Object) of all key/value pairs in <var>map</var>

Remove(Object)

Remove an existing key from the array map.

RemoveAll(ICollection<Object>)

Remove all keys in the array map that exist in the given collection.

RemoveAt(Int32)

Remove the key/value mapping at the given index.

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.

RetainAll(ICollection<Object>)

Remove all keys in the array map that do <b>not</b> exist in the given collection.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetValueAt(Int32, Object)

Set the value at a given index in the array.

Size()

Return the number of items in this array map.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
ValueAt(Int32)

Return the value at the given index in the array.

Values()

Return a java.util.Collection for iterating over and interacting with all values in the array map.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed()

Notifies the interop runtime that this managed peer has been disposed.

(Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced()

Releases this Java peer unless it is retained by another managed reference.

(Inherited from Object)
IJavaPeerable.Finalized()

Notifies the interop runtime that this managed peer has been finalized.

(Inherited from Object)
IJavaPeerable.JniManagedPeerState

Gets the state that describes the relationship between this managed peer and its JNI reference.

(Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32)

Sets the interop identity hash code for this Java peer.

(Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

Sets the managed and JNI peer state for this Java peer.

(Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference)

Sets the JNI object reference used by this managed peer.

(Inherited from Object)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to