put All elements from one SparseArray to another SparseArray - Android android.util

Android examples for android.util:SparseArray

Description

put All elements from one SparseArray to another SparseArray

Demo Code

import android.util.SparseArray;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static <E> SparseArray<E> putAll(SparseArray<E> source,
            SparseArray<E> dest) {
        if (dest == null)
            dest = source;//from  w  w w  .  j  av a  2s.c  om
        else if (source != null)
            for (int i = 0; i < source.size(); i++) {
                int key = source.keyAt(i);
                E value = source.valueAt(i);
                dest.put(key, value);
            }
        return dest;
    }

}

Related Tutorials