Android SparseBooleanArray Search getIndexesFromSparseBooleanArray( SparseBooleanArray array, boolean value)

Here you can find the source of getIndexesFromSparseBooleanArray( SparseBooleanArray array, boolean value)

Description

Retrieves the existing integer indexes coming from provided SparseBooleanArray under which there is certain boolean value set.

Declaration

public static List<Integer> getIndexesFromSparseBooleanArray(
        SparseBooleanArray array, boolean value) 

Method Source Code

//package com.java2s;
import android.util.SparseBooleanArray;
import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from w  w  w  .j a v a  2 s  .  c  o  m*/
     * Retrieves the existing integer indexes coming from provided {@link SparseBooleanArray} under which there is
     * certain boolean {@code value} set.
     */
    public static List<Integer> getIndexesFromSparseBooleanArray(
            SparseBooleanArray array, boolean value) {
        List<Integer> result = new ArrayList<Integer>();
        for (int i = 0; i < array.size(); i++) {
            if (array.valueAt(i) == value) {
                result.add(array.keyAt(i));
            }
        }
        return result;
    }
}