java.lang.Object | |
↳ | android.support.v4.util.SimpleArrayMap<K, V> |
Known Direct Subclasses
ArrayMap
<K, V>
|
Base implementation of
ArrayMap
that doesn't include any standard Java
container API interoperability. These features are generally heavier-weight ways
to interact with the container, so discouraged, but they can be useful to make it
easier to use as a drop-in replacement for HashMap. If you don't need them, this
class can be preferrable since it doesn't bring in any of the implementation of those
APIs, allowing that code to be stripped by ProGuard.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Create a new empty ArrayMap.
|
||||||||||
|
Create a new ArrayMap with a given initial capacity.
|
||||||||||
|
Create a new ArrayMap with the mappings from the given ArrayMap.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Make the array map empty.
|
||||||||||
|
Check whether a key exists in the array.
|
||||||||||
|
Check whether a value exists in the array.
|
||||||||||
|
Ensure the array map can hold at least
minimumCapacity
items.
|
||||||||||
|
Compares this instance with the specified object and indicates if they
are equal.
This implementation returns false if the object is not a map, or if the maps have different sizes. |
||||||||||
|
Retrieve a value from the array.
|
||||||||||
|
Returns an integer hash code for this object.
|
||||||||||
|
Return true if the array map contains no items.
|
||||||||||
|
Return the key at the given index in the array.
|
||||||||||
|
Add a new value to the array map.
|
||||||||||
|
Perform a
put(Object, Object)
of all key/value pairs in
array
|
||||||||||
|
Remove an existing key from the array map.
|
||||||||||
|
Remove the key/value mapping at the given index.
|
||||||||||
|
Set the value at a given index in the array.
|
||||||||||
|
Return the number of items in this array map.
|
||||||||||
|
Returns a string containing a concise, human-readable description of this
object.
This implementation composes a string by iterating over its mappings. |
||||||||||
|
Return the value at the given index in the array.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a new empty ArrayMap. The default capacity of an array map is 0, and will grow once items are added to it.
Create a new ArrayMap with a given initial capacity.
Create a new ArrayMap with the mappings from the given ArrayMap.
Make the array map empty. All storage is released.
Check whether a key exists in the array.
key | The key to search for. |
---|
Check whether a value exists in the array. This requires a linear search through the entire array.
value | The value to search for. |
---|
Ensure the array map can hold at least minimumCapacity items.
Compares this instance with the specified object and indicates if they
are equal. In order to be equal,
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns
true
only if
this ==
o
. See
Writing a correct
equals
method
if you intend implementing your own
equals
method.
The general contract for the
equals
and
hashCode()
methods is that if
equals
returns
true
for
any two objects, then
hashCode()
must return the same value for
these objects. This means that subclasses of
Object
usually
override either both methods or neither of them.
This implementation returns false if the object is not a map, or if the maps have different sizes. Otherwise, for each key in this map, values of both maps are compared. If the values for any key are not equal, the method returns false, otherwise it returns true.
object | the object to compare this instance with. |
---|
true
if the specified object is equal to this
Object
;
false
otherwise.
Retrieve a value from the array.
key | The key of the value to retrieve. |
---|
Returns an integer hash code for this object. By contract, any two
objects for which
equals(Object)
returns
true
must return
the same hash code value. This means that subclasses of
Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See
Writing a correct
hashCode
method
if you intend implementing your own
hashCode
method.
Return true if the array map contains no items.
Return the key at the given index in the array.
index |
The desired index, must be between 0 and
size()
-1.
|
---|
Add a new value to the array map.
key | The key under which to store the value. Must not be null. If this key already exists in the array, its value will be replaced. |
---|---|
value | The value to store for the given key. |
Perform a
put(Object, Object)
of all key/value pairs in
array
array | The array whose contents are to be retrieved. |
---|
Remove an existing key from the array map.
key | The key of the mapping to remove. |
---|
Remove the key/value mapping at the given index.
index |
The desired index, must be between 0 and
size()
-1.
|
---|
Set the value at a given index in the array.
index |
The desired index, must be between 0 and
size()
-1.
|
---|---|
value | The new value to store at this index. |
Return the number of items in this array map.
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
See
Writing a useful
toString
method
if you intend implementing your own
toString
method.
This implementation composes a string by iterating over its mappings. If this map contains itself as a key or a value, the string "(this Map)" will appear in its place.
Return the value at the given index in the array.
index |
The desired index, must be between 0 and
size()
-1.
|
---|