## org.eclipse.emf.validation.util
Class FilteredCollection<E>

    java.lang.Object
      java.util.AbstractCollection<E>
          org.eclipse.emf.validation.util.FilteredCollection<E>

Type Parameters:
  `E` - the collection element type

All Implemented Interfaces:
  Iterable<E>, Collection<E>

    public class FilteredCollection<E>

extends AbstractCollection<E>

Wrapper for a Java 2 `Collection` that provides a filtered view of its contents according to a client-specified filter algorithm.

Nested Class Summary
`static interface` `FilteredCollection.Filter<E>` Interface for the algorithm that determines which elements are in and which are out of the filtered collection.

Constructor Summary
`FilteredCollection(Collection<? extends E> collection, FilteredCollection.Filter<? super E> filter)` Initializes me to filter the specified collection, obtained independently.

Method Summary
`FilteredCollection.Filter<? super E>` `getFilter()` Retrieves the filter with which I was initialized.
`Iterator<E>` `iterator()` Obtains an iterator that dynamically filters out unwanted items using my `filter` algorithm.
`int` `size()` Computes the size of the filtered view, i.e.

Methods inherited from class java.util.AbstractCollection
`add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Collection
`equals, hashCode`

Constructor Detail

### FilteredCollection

    public FilteredCollection(Collection<? extends E> collection,
                              FilteredCollection.Filter<? super E> filter)

  Initializes me to filter the specified collection, obtained independently.

  Note that it is a very bad idea to modify the wrapped `collection` after creating this filtered view on it. The results are undefined, but probably not what you want.

  Parameters:
    `collection` - the collection that I am to filter
    `filter` - the filter algorithm to apply

Method Detail

### getFilter

    public final FilteredCollection.Filter<? super E> getFilter()

  Retrieves the filter with which I was initialized. Note that the result of modifying this filter's algorithm while I am using it is undefined, but not likely to be what you want.

  Returns:
    my filter

### iterator

    public Iterator<E> iterator()

  Obtains an iterator that dynamically filters out unwanted items using my `filter` algorithm.

  Specified by:
    `iterator` in interface `Iterable<E>`
  Specified by:
    `iterator` in interface `Collection<E>`
  Specified by:
    `iterator` in class `AbstractCollection<E>`
  Returns:
    an iterator the exposes only the elements of my wrapped collection that match my filter

### size

    public int size()

  Computes the size of the filtered view, i.e. the number of elements in the original collection that match my `filter`, by iterating myself.

  Note that my size is recounted every time that it is requested, in case my filter's algorithm is changed or the contents of the underlying collection are changed.

  Specified by:
    `size` in interface `Collection<E>`
  Specified by:
    `size` in class `AbstractCollection<E>`
  Returns:
    the number of elements in my wrapped collection that match my filter

Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved.