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

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

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 (Inherited from Object)
JniPeerMembers
PeerReference (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

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() (Inherited from Object)
Dispose(Boolean) (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>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (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)

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, 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)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to