data/TWiki/TWikiAggregateIteratorDotPm.txt
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
colas@0
     1
---+ Package =TWiki::AggregateIterator=
colas@0
     2
colas@0
     3
combine multiple iterators
colas@0
     4
colas@0
     5
colas@0
     6
%TOC%
colas@0
     7
colas@0
     8
---++ new(\@list, $unique)
colas@0
     9
colas@0
    10
Create a new iterator over the given list of iterators. The list is not damaged in
colas@0
    11
any way.
colas@0
    12
colas@0
    13
if $unique is set, we try to not repeat values.
colas@0
    14
Warning: $unique assumes that the values are strings (so works for cUID's )
colas@0
    15
colas@0
    16
colas@0
    17
---++ hasNext() -> $boolean
colas@0
    18
colas@0
    19
Returns false when the iterator is exhausted.
colas@0
    20
colas@0
    21
<verbatim>
colas@0
    22
my $it = new TWiki::ListIterator(\@list);
colas@0
    23
while ($it->hasNext()) {
colas@0
    24
   ...
colas@0
    25
</verbatim>
colas@0
    26
colas@0
    27
colas@0
    28
---++ next() -> $data
colas@0
    29
colas@0
    30
Return the next entry in the list.
colas@0
    31
colas@0
    32
The iterator object can be customised to pre- and post-process entries from
colas@0
    33
the list before returning them. This is done by setting two fields in the
colas@0
    34
iterator object:
colas@0
    35
colas@0
    36
   * ={filter}= can be defined to be a sub that filters each entry. The entry
colas@0
    37
     will be ignored (next() will not return it) if the filter returns false.
colas@0
    38
   * ={process}= can be defined to be a sub to process each entry before it
colas@0
    39
     is returned by next. The value returned from next is the value returned
colas@0
    40
     by the process function.
colas@0
    41
colas@0
    42