POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: A test Server Time
30 Sep 2024 19:28:16 EDT (-0400)
  Re: A test  
From: Warp
Date: 24 Sep 2008 09:42:32
Message: <48da43c8@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.