am 550ae6db: am 2430f47b: Merge "Add ArraySet to the SDK." into mnc-dev

* commit '550ae6db7f888cf6431c339274973faee352a507':
  Add ArraySet to the SDK.
This commit is contained in:
Dianne Hackborn
2015-06-11 23:36:06 +00:00
committed by Android Git Automerger
4 changed files with 87 additions and 8 deletions

View File

@@ -33906,7 +33906,7 @@ package android.util {
public final class ArrayMap implements java.util.Map {
ctor public ArrayMap();
ctor public ArrayMap(int);
ctor public ArrayMap(android.util.ArrayMap);
ctor public ArrayMap(android.util.ArrayMap<K, V>);
method public void clear();
method public boolean containsAll(java.util.Collection<?>);
method public boolean containsKey(java.lang.Object);
@@ -33931,6 +33931,31 @@ package android.util {
method public java.util.Collection<V> values();
}
public final class ArraySet implements java.util.Collection java.util.Set {
ctor public ArraySet();
ctor public ArraySet(int);
ctor public ArraySet(android.util.ArraySet<E>);
method public boolean add(E);
method public void addAll(android.util.ArraySet<? extends E>);
method public boolean addAll(java.util.Collection<? extends E>);
method public void clear();
method public boolean contains(java.lang.Object);
method public boolean containsAll(java.util.Collection<?>);
method public void ensureCapacity(int);
method public int indexOf(java.lang.Object);
method public boolean isEmpty();
method public java.util.Iterator<E> iterator();
method public boolean remove(java.lang.Object);
method public boolean removeAll(android.util.ArraySet<? extends E>);
method public boolean removeAll(java.util.Collection<?>);
method public E removeAt(int);
method public boolean retainAll(java.util.Collection<?>);
method public int size();
method public java.lang.Object[] toArray();
method public T[] toArray(T[]);
method public E valueAt(int);
}
public class AtomicFile {
ctor public AtomicFile(java.io.File);
method public void delete();

View File

@@ -36183,7 +36183,7 @@ package android.util {
public final class ArrayMap implements java.util.Map {
ctor public ArrayMap();
ctor public ArrayMap(int);
ctor public ArrayMap(android.util.ArrayMap);
ctor public ArrayMap(android.util.ArrayMap<K, V>);
method public void clear();
method public boolean containsAll(java.util.Collection<?>);
method public boolean containsKey(java.lang.Object);
@@ -36208,6 +36208,31 @@ package android.util {
method public java.util.Collection<V> values();
}
public final class ArraySet implements java.util.Collection java.util.Set {
ctor public ArraySet();
ctor public ArraySet(int);
ctor public ArraySet(android.util.ArraySet<E>);
method public boolean add(E);
method public void addAll(android.util.ArraySet<? extends E>);
method public boolean addAll(java.util.Collection<? extends E>);
method public void clear();
method public boolean contains(java.lang.Object);
method public boolean containsAll(java.util.Collection<?>);
method public void ensureCapacity(int);
method public int indexOf(java.lang.Object);
method public boolean isEmpty();
method public java.util.Iterator<E> iterator();
method public boolean remove(java.lang.Object);
method public boolean removeAll(android.util.ArraySet<? extends E>);
method public boolean removeAll(java.util.Collection<?>);
method public E removeAt(int);
method public boolean retainAll(java.util.Collection<?>);
method public int size();
method public java.lang.Object[] toArray();
method public T[] toArray(T[]);
method public E valueAt(int);
}
public class AtomicFile {
ctor public AtomicFile(java.io.File);
method public void delete();

View File

@@ -266,7 +266,7 @@ public final class ArrayMap<K, V> implements Map<K, V> {
/**
* Create a new ArrayMap with the mappings from the given ArrayMap.
*/
public ArrayMap(ArrayMap map) {
public ArrayMap(ArrayMap<K, V> map) {
this();
if (map != null) {
putAll(map);
@@ -843,7 +843,8 @@ public final class ArrayMap<K, V> implements Map<K, V> {
* in the array map.
*
* <p><b>Note:</b> this is a very inefficient way to access the array contents, it
* requires generating a number of temporary objects.</p>
* requires generating a number of temporary objects and allocates additional state
* information associated with the container that will remain for the life of the container.</p>
*
* <p><b>Note:</b></p> the semantics of this
* Set are subtly different than that of a {@link java.util.HashMap}: most important,
@@ -861,7 +862,8 @@ public final class ArrayMap<K, V> implements Map<K, V> {
* in the array map.
*
* <p><b>Note:</b> this is a fairly inefficient way to access the array contents, it
* requires generating a number of temporary objects.</p>
* requires generating a number of temporary objects and allocates additional state
* information associated with the container that will remain for the life of the container.</p>
*/
@Override
public Set<K> keySet() {
@@ -873,7 +875,8 @@ public final class ArrayMap<K, V> implements Map<K, V> {
* in the array map.
*
* <p><b>Note:</b> this is a fairly inefficient way to access the array contents, it
* requires generating a number of temporary objects.</p>
* requires generating a number of temporary objects and allocates additional state
* information associated with the container that will remain for the life of the container.</p>
*/
@Override
public Collection<V> values() {

View File

@@ -42,8 +42,6 @@ import java.util.Set;
* 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.</p>
*
* @hide
*/
public final class ArraySet<E> implements Collection<E>, Set<E> {
private static final boolean DEBUG = false;
@@ -660,11 +658,24 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
return mCollections;
}
/**
* Return an {@link java.util.Iterator} over all values in the set.
*
* <p><b>Note:</b> this is a fairly inefficient way to access the array contents, it
* requires generating a number of temporary objects and allocates additional state
* information associated with the container that will remain for the life of the container.</p>
*/
@Override
public Iterator<E> iterator() {
return getCollection().getKeySet().iterator();
}
/**
* Determine if the array set contains all of the values in the given collection.
* @param collection The collection whose contents are to be checked against.
* @return Returns true if this array set contains a value for every entry
* in <var>collection</var>, else returns false.
*/
@Override
public boolean containsAll(Collection<?> collection) {
Iterator<?> it = collection.iterator();
@@ -676,6 +687,10 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
return true;
}
/**
* Perform an {@link #add(Object)} of all values in <var>collection</var>
* @param collection The collection whose contents are to be retrieved.
*/
@Override
public boolean addAll(Collection<? extends E> collection) {
ensureCapacity(mSize + collection.size());
@@ -686,6 +701,11 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
return added;
}
/**
* Remove all values in the array set that exist in the given collection.
* @param collection The collection whose contents are to be used to remove values.
* @return Returns true if any values were removed from the array set, else false.
*/
@Override
public boolean removeAll(Collection<?> collection) {
boolean removed = false;
@@ -695,6 +715,12 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
return removed;
}
/**
* Remove all values in the array set that do <b>not</b> exist in the given collection.
* @param collection The collection whose contents are to be used to determine which
* values to keep.
* @return Returns true if any values were removed from the array set, else false.
*/
@Override
public boolean retainAll(Collection<?> collection) {
boolean removed = false;