
solid.converters.ToSparseArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solid Show documentation
Show all versions of solid Show documentation
Solid is an Android library, which provides lightweight data streams and immutable+parcelable collections.
package solid.converters;
import android.util.SparseArray;
import solid.functions.SolidFunc1;
public class ToSparseArray implements SolidFunc1, SparseArray> {
public static ToSparseArray toSparseArray(SolidFunc1 itemToKey, int initialCapacity) {
return new ToSparseArray<>(itemToKey, initialCapacity);
}
public static ToSparseArray toSparseArray(SolidFunc1 itemToKey) {
return new ToSparseArray<>(itemToKey);
}
private SolidFunc1 getItemKey;
private int initialCapacity;
public ToSparseArray(SolidFunc1 itemToKey) {
this(itemToKey, 10);
}
public ToSparseArray(SolidFunc1 itemToKey, int initialCapacity) {
this.getItemKey = itemToKey;
this.initialCapacity = initialCapacity;
}
@Override
public SparseArray call(Iterable iterable) {
SparseArray array = new SparseArray<>(initialCapacity);
for (T value : iterable)
array.put(getItemKey.call(value), value);
return array;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy