Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bouncycastle.util;
 
 import java.util.List;

A simple collection backed store.
public class CollectionStore<T>
    implements Store<T>, Iterable<T>
    private Collection<T> _local;

    
Basic constructor.

Parameters:
collection - initial contents for the store, this is copied.
    public CollectionStore(
        Collection<T> collection)
    {
         = new ArrayList<T>(collection);
    }

    
Return the matches in the collection for the passed in selector.

Parameters:
selector the selector to match against.
Returns:
a possibly empty collection of matching objects.
    public Collection<T> getMatches(Selector<T> selector)
    {
        if (selector == null)
        {
            return new ArrayList<T>();
        }
        else
        {
            List<T> col = new ArrayList<T>();
            Iterator<T> iter = .iterator();
            while (iter.hasNext())
            {
                T obj = iter.next();
                if (selector.match(obj))
                {
                    col.add(obj);
                }
            }
            return col;
        }
    }
    public Iterator<T> iterator()
    {
        return getMatches(null).iterator();
    }
New to GrepCode? Check out our FAQ X