FileDocCategorySizeDatePackage
FastImmutableArraySet.javaAPI DocAndroid 5.1 API2204Thu Mar 12 22:22:10 GMT 2015android.util

FastImmutableArraySet

public final class FastImmutableArraySet extends AbstractSet
A fast immutable set wrapper for an array that is optimized for non-concurrent iteration. The same iterator instance is reused each time to avoid creating lots of garbage. Iterating over an array in this fashion is 2.5x faster than iterating over a {@link HashSet} so it is worth copying the contents of the set to an array when iterating over it hundreds of times.
hide

Fields Summary
FastIterator
mIterator
T[]
mContents
Constructors Summary
public FastImmutableArraySet(T[] contents)

        mContents = contents;
    
Methods Summary
public java.util.Iteratoriterator()

        FastIterator<T> it = mIterator;
        if (it == null) {
            it = new FastIterator<T>(mContents);
            mIterator = it;
        } else {
            it.mIndex = 0;
        }
        return it;
    
public intsize()

        return mContents.length;