|
|
Invisible <voi### [at] devnull> wrote:
> Warp wrote:
> > Or I could simply make an overloaded version of the fold function which
> > takes an iterator range.
> Now what happens if you want to only process elements having some
> arbitrary property? (E.g., only the odd numbers.)
I make the function take a functor which tells which elements to process.
This is a standard technique in C++.
> Or what if the
> function you're trying to fold is non-associative, and you want to
> rearrange the list so the elements can be processed in a different order?
Then rearrange the list as you like and give it to the function?
> If you really need killer performance on a critical region of your
> program... well actually, in that case you probably wouldn't be using
> lists anyway, but still...
There are algorithms for which linked lists are the most efficient
data container. You still don't want to be needlessly copying the elements
around, though.
--
- Warp
Post a reply to this message
|
|