Skip to content

Instantly share code, notes, and snippets.

@TheFinestArtist
Created July 25, 2015 14:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFinestArtist/44e50101c4f6f31c5188 to your computer and use it in GitHub Desktop.
Save TheFinestArtist/44e50101c4f6f31c5188 to your computer and use it in GitHub Desktop.
SparseArrayHelper.java
import android.util.SparseArray;
import java.util.ArrayList;
/**
* SparseArrayHelper
*
* Created by TheFinestArtist
*/
public class SparseArrayHelper {
public static <C> ArrayList<C> asArrayList(SparseArray<C> sparseArray) {
if (sparseArray == null) return new ArrayList<C>();
ArrayList<C> arrayList = new ArrayList<C>(sparseArray.size());
for (int i = 0; i < sparseArray.size(); i++)
arrayList.add(sparseArray.valueAt(i));
return arrayList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment