I am not acquainted with the ELF and what functionality a potential user may desire from your module. So I will risk some general points.

Filtering (the ELF segments) can be important and could even expand to checks other than size>0. In both get() methods you do this filtering by hand, inside the loop. If indeed there is scope for filtering useless segments and selecting "interesting" (hmmmm!!) segments then I would re-pose the problem. It looks to me that such a functionality would be very appealing. But is the array or the iterator suited for this best? Usually when filtering, one expects the result collection to be of the same type as the input, e.g. an array or iterator (Edit: and even offer in-place editing). Neither looks suitable though for filtering! Splicing an array? Linkedlist?

There is also the question of passing the segments, array or iterator, to another sub/module for further processing, filtering, profiling etc. I would think an arrayref is the least common denominator here. Unless that other module is yours and you control the API.

But there is also the problem of creating new iterators to return back after filtering and selecting. Possibly pipelined. Would (not-)garbage-collecting the iterators be a problem?

As I said I am ignorant about ELF, but perhaps it makes sense to store the segments in a linkedlist/graph/tree? Perhaps for adding/removing a new segment and then writing out the ELF?


In reply to Re: Index or iterate - your choice by bliako
in thread Index or iterate - your choice by GrandFather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.