Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Iterator 0.03

    Download button

    No screenshots available
    Downloads: 293  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Eric J. Roode | More programs
    Perl Artistic License / FREE
    May 18th, 2007, 18:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Iterator description

    Iterator is a general-purpose iterator class.

    Iterator is a general-purpose iterator class.

    SYNOPSIS

    use Iterator;

    # Making your own iterators from scratch:
    $iterator = Iterator->new ( sub { code } );

    # Accessing an iterator's values in turn:
    $next_value = $iterator->value();

    # Is the iterator out of values?
    $boolean = $iterator->is_exhausted();
    $boolean = $iterator->isnt_exhausted();

    # Within {code}, above:
    Iterator::is_done(); # to signal end of sequence.

    This module is meant to be the definitive implementation of iterators, as popularized by Mark Jason Dominus's lectures and recent book (Higher Order Perl, Morgan Kauffman, 2005).

    An "iterator" is an object, represented as a code block that generates the "next value" of a sequence, and generally implemented as a closure. When you need a value to operate on, you pull it from the iterator. If it depends on other iterators, it pulls values from them when it needs to. Iterators can be chained together (see Iterator::Util for functions that help you do just that), queueing up work to be done but not actually doing it until a value is needed at the front end of the chain. At that time, one data value is pulled through the chain.

    Contrast this with ordinary array processing, where you load or compute all of the input values at once, then loop over them in memory. It's analogous to the difference between looping over a file one line at a time, and reading the entire file into an array of lines before operating on it.

    Iterator.pm provides a class that simplifies creation and use of these iterator objects. Other Iterator:: modules (see "SEE ALSO") provide many general-purpose and special-purpose iterator functions.

    Some iterators are infinite (that is, they generate infinite sequences), and some are finite. When the end of a finite sequence is reached, the iterator code block should throw an exception of the type Iterator::X::Am_Now_Exhausted; this is usually done via the "is_done" function.. This will signal the Iterator class to mark the object as exhausted. The "is_exhausted" method will then return true, and the "isnt_exhausted" method will return false. Any further calls to the "value" method will throw an exception of the type Iterator::X::Exhausted.

    Note that in many, many cases, you will not need to explicitly create an iterator; there are plenty of iterator generation and manipulation functions in the other associated modules. You can just plug them together like building blocks.

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    iterator class | create iterators | Perl module | Iterator | iterator | class

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM