All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dm.rf.android.v4.SparseCollections Maven / Gradle / Ivy

/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.dm.rf.android.v4;

import android.support.v4.util.LongSparseArray;
import android.support.v4.util.SimpleArrayMap;
import android.support.v4.util.SparseArrayCompat;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;

import com.github.dm.rf.android.internal.CompatIterableFactory;
import com.github.dm.rf.android.iterator.SimpleArrayMapIterable;
import com.github.dm.rf.android.iterator.SparseArrayCompatIterable;
import com.github.dm.rf.android.iterator.SparseArrayIterable;
import com.github.dm.rf.android.iterator.SparseBooleanArrayIterable;
import com.github.dm.rf.android.iterator.SparseIntArrayIterable;
import com.github.dm.rf.android.iterator.SupportLongSparseArrayIterable;

/**
 * This utility class creates objects wrapping an Android sparse collection, such as
 * {@link android.util.SparseArray} and {@link android.support.v4.util.SparseArrayCompat}, to give
 * it the base functionalities of an {@link java.lang.Iterable} object.
 * 

* Created by davide-maestroni on 3/9/14. */ public class SparseCollections { /** * Avoid direct instantiation. */ protected SparseCollections() { } /** * Wraps the specified {@link android.support.v4.util.SimpleArrayMap} into an iterable. * * @param arrayMap the array map to wrap. * @param the element key type. * @param the element value type. * @return the iterable instance. */ public static SimpleArrayMapIterable iterate(final SimpleArrayMap arrayMap) { return CompatIterableFactory.create(arrayMap); } /** * Wraps the specified {@link android.support.v4.util.LongSparseArray} into an iterable. * * @param sparseArray the sparse array to wrap. * @param the element value type. * @return the iterable instance. */ public static SupportLongSparseArrayIterable iterate( final LongSparseArray sparseArray) { return CompatIterableFactory.create(sparseArray); } /** * Wraps the specified {@link android.util.SparseArray} into an iterable. * * @param sparseArray the sparse array to wrap. * @param the element value type. * @return the iterable instance. */ public static SparseArrayIterable iterate(final SparseArray sparseArray) { return CompatIterableFactory.create(sparseArray); } /** * Wraps the specified {@link android.support.v4.util.SparseArrayCompat} into an iterable. * * @param sparseArray the sparse array to wrap. * @param the element value type. * @return the iterable instance. */ public static SparseArrayCompatIterable iterate(final SparseArrayCompat sparseArray) { return CompatIterableFactory.create(sparseArray); } /** * Wraps the specified {@link android.util.SparseIntArray} into an iterable. * * @param sparseArray the sparse array to wrap. * @return the iterable instance. */ public static SparseIntArrayIterable iterate(final SparseIntArray sparseArray) { return CompatIterableFactory.create(sparseArray); } /** * Wraps the specified {@link android.util.SparseBooleanArray} into an iterable. * * @param sparseArray the sparse array to wrap. * @return the iterable instance. */ public static SparseBooleanArrayIterable iterate(final SparseBooleanArray sparseArray) { return CompatIterableFactory.create(sparseArray); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy