package com.oasisfeng.android.util;

import android.util.SparseArray;

import java.util.Iterator;

/**
 * Utilities for {@link android.util.SparseIntArray}
 *
 * Created by Oasis on 2017/1/7.
 */
public class SparseArrays {

	public static <T> Iterable<T> iterate(final SparseArray<T> array) {
		return new Iterable<T>() { @Override public Iterator<T> iterator() {
			return new Iterator<T>() {
				@Override public boolean hasNext() { return i < array.size(); }
				@Override public T next() { return array.valueAt(i ++); }
				int i = 0;
			};
		}};
	}
}

@@ -30,16 +30,125 @@
 .util;%0A%0A
+import android.os.Build;%0Aimport android.support.annotation.RequiresApi;%0Aimport android.util.LongSparseArray;%0A
 import a
@@ -656,11 +656,392 @@
 %09%09%7D%7D;%0A%09%7D
+%0A%0A%09@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)%0A%09public static %3CT%3E Iterable%3CT%3E iterate(final LongSparseArray%3CT%3E array) %7B%0A%09%09return new Iterable%3CT%3E() %7B @Override public Iterator%3CT%3E iterator() %7B%0A%09%09%09return new Iterator%3CT%3E() %7B%0A%09%09%09%09@Override public boolean hasNext() %7B return i %3C array.size(); %7D%0A%09%09%09%09@Override public T next() %7B return array.valueAt(i ++); %7D%0A%09%09%09%09int i = 0;%0A%09%09%09%7D;%0A%09%09%7D%7D;%0A%09%7D
 %0A%7D%0A

Support LongSparseArray in SparseArrays.iterate() overloads.