Android SparseBooleanArray Convert toSet(SparseBooleanArray array)

Here you can find the source of toSet(SparseBooleanArray array)

Description

to Set

License

Apache License

Declaration

public static Set<Integer> toSet(SparseBooleanArray array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Set;
import android.util.SparseBooleanArray;

import com.google.common.collect.Sets;

public class Main {
    public static Set<Integer> toSet(SparseBooleanArray array) {
        Set<Integer> trueSet = Sets.newHashSet();
        for (int i = 0; i < array.size(); i++) {
            if (array.valueAt(i)) {
                int position = array.keyAt(i);
                trueSet.add(position);/*  w w  w .  j  a v  a  2s .  c o  m*/
            }
        }
        return trueSet;
    }
}

Related

  1. toMap(SparseBooleanArray array)