• class FilteringIterator (T): Iterator!(T);
  • FilteringIterators allow you to filter out elements from other enumerations before they are seen by their `consumers' (i.e., the callers of `get').

    FilteringIterators work as wrappers around other Iterators. To build one, you need an existing Iterator (perhaps one from coll.elements(), for some Collection coll), and a Predicate object (i.e., implementing interface Predicate). For example, if you want to screen out everything but Panel objects from a collection coll that might hold things other than Panels, write something of the form:
     Iterator e = coll.elements();
     Iterator panels = FilteringIterator(e, IsPanel);
     while (panels.more())
      doSomethingWith(cast(Panel)(panels.get()));
    
    To use this, you will also need to write a little class of the form:
     class IsPanel : Predicate {
      bool predicate(Object v) { return cast(Panel) v !is null; }
     }
    


    See Also:
    tango.util.collection.Predicate.predicate

    author:
    Doug Lea

  • Iterator!(T) src_ ;
  • The enumeration we are wrapping

  • Predicate pred_ ;
  • The screening predicate

  • bool sign_ ;
  • The sense of the predicate. False means to invert

  • T get_ ;
  • The next element to hand out

  • bool haveNext_ ;
  • True if we have a next element

  • this(Iterator!(T) src, Predicate p);
  • Make a Filter using src for the elements, and p as the screener, selecting only those elements of src for which p is true

  • this(Iterator!(T) src, Predicate p, bool sense);
  • Make a Filter using src for the elements, and p as the screener, selecting only those elements of src for which p.predicate(v) == sense. A value of true for sense selects only values for which p.predicate is true. A value of false selects only those for which it is false.

  • bool more ();
  • Implements tango.util.collection.model.Iterator. more

  • T get ();
  • Implements tango.util.collection.model.Iterator. get .

  • void findNext ();
  • Traverse through src_ elements finding one passing predicate

    :: page rendered by CandyDoc