List of usage examples for android.util LongSparseArray append
public void append(long key, E value)
From source file:com.bmd.android.collection.LongSparseArrayTest.java
@Override protected void setUp() throws Exception { super.setUp(); if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { return;/*from www.j ava 2s .c o m*/ } final LongSparseArray<String> array = new LongSparseArray<String>(); for (int i = 0; i < 5; i++) { array.append(i, String.valueOf(i)); } mArray = array; }
From source file:com.bmd.android.collection.LongSparseArrayTest.java
public void testEquals() { if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { return;//from www. j ava 2 s. co m } final android.support.v4.util.LongSparseArray<String> supportArray = new android.support.v4.util.LongSparseArray<String>(); for (int i = 0; i < 5; i++) { supportArray.append(i, String.valueOf(i)); } assertThat(AndroidCollections.iterate(mArray).isStrictlyEqualTo(AndroidCollections.iterate(supportArray))) .isTrue(); assertThat(AndroidCollections.iterate(supportArray).isStrictlyEqualTo(AndroidCollections.iterate(mArray))) .isTrue(); assertThat(AndroidCollections.iterate(supportArray).only().key(2).remove() .isStrictlyEqualTo(AndroidCollections.iterate(mArray))).isFalse(); assertThat(AndroidCollections.iterate(mArray).isStrictlyEqualTo(AndroidCollections.iterate(supportArray))) .isFalse(); final LongSparseArray<String> sparseArray = AndroidCollections.iterate(mArray).toSparseArray(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(mArray)).isTrue(); assertThat(AndroidCollections.iterate(mArray).only().first(2).isEqualTo(mArray)).isFalse(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(sparseArray)).isTrue(); assertThat(AndroidCollections.iterate(mArray).only().first(2).isEqualTo(sparseArray)).isFalse(); final ArrayList<LongSparseObjectEntry<String>> list = AndroidCollections.iterate(mArray).toImmutableList(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(list)).isTrue(); assertThat(AndroidCollections.iterate(mArray).only().first(2).isEqualTo(list)).isFalse(); final ArrayList<ParcelableLongSparseObjectEntry<String>> parcelableList = AndroidCollections.iterate(mArray) .toParcelableList(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(parcelableList)).isTrue(); assertThat(AndroidCollections.iterate(mArray).only().first(2).isEqualTo(parcelableList)).isFalse(); final Map<Long, String> map = AndroidCollections.iterate(mArray).toMap(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(map)).isTrue(); assertThat(AndroidCollections.iterate(mArray).only().first(2).isEqualTo(map)).isFalse(); final SortedMap<Long, String> sortedMap = AndroidCollections.iterate(mArray).toSortedMap(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(sortedMap)).isTrue(); assertThat(AndroidCollections.iterate(mArray).only().first(2).isEqualTo(sortedMap)).isFalse(); mArray.append(7, "7"); assertThat(AndroidCollections.iterate(mArray).isEqualTo(sparseArray)).isFalse(); assertThat(AndroidCollections.iterate(mArray).but().last(1).isEqualTo(sparseArray)).isTrue(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(list)).isFalse(); assertThat(AndroidCollections.iterate(mArray).but().last(1).isEqualTo(list)).isTrue(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(parcelableList)).isFalse(); assertThat(AndroidCollections.iterate(mArray).but().last(1).isEqualTo(parcelableList)).isTrue(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(map)).isFalse(); assertThat(AndroidCollections.iterate(mArray).but().last(1).isEqualTo(map)).isTrue(); assertThat(AndroidCollections.iterate(mArray).isEqualTo(sortedMap)).isFalse(); assertThat(AndroidCollections.iterate(mArray).but().last(1).isEqualTo(sortedMap)).isTrue(); }