Clones a SparseArray. - Android android.util

Android examples for android.util:SparseArray

Description

Clones a SparseArray.

Demo Code


//package com.java2s;

import android.util.SparseArray;

public class Main {
    /** Clones a SparseArray. */
    public static <E> SparseArray<E> cloneSparseArray(SparseArray<E> orig) {
        SparseArray<E> result = new SparseArray<E>();
        for (int i = 0; i < orig.size(); i++) {
            result.put(orig.keyAt(i), orig.valueAt(i));
        }/* www. j  a  va2  s  .  c  om*/
        return result;
    }
}

Related Tutorials