Thirrash / gnuplot-cpp

Automatically exported from code.google.com/p/gnuplot-cpp
0 stars 0 forks source link

Using iterators instead of [i] #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
- Not applicable

What is the expected output? What do you see instead?
- Not applicable.

What version of the product are you using? On what operating system?
- Gentoo Linux amd64, 2.6.31

Please provide any additional information below.
- I checked out head from svn today (03 Dec 2009) and am finding this code
very useful. After going through the code, I find that all plot functions
use templates for storing data variable; however the [] operator used to
access individual data elements restricts templates to those containers
that define the [] operator (such as std::vector). It might be more useful
if elements are accessed using iterators instead as it will allow use of
greater range of containers.

Original issue reported on code.google.com by aditya.gadre@gmail.com on 3 Dec 2009 at 5:49

GoogleCodeExporter commented 8 years ago
[] is much faster then using iterators, specially if data to be plotted is 
large. However, if the program is already generating data in container other 
then vector; then building a vector out of other container to pass to gnuplot 
functions and then discard afterwards; is bad. :-)

Original comment by am...@agoel.com on 18 Sep 2013 at 12:28

GoogleCodeExporter commented 8 years ago
I doubt `[]` is "much faster" than iterators (which, for vectors, are just 
pointers ... and guess what `[]` does?).

However, to defend your point, you could argue that requiring Random Access 
makes sense here because of the nature of the data... and using `[]` 
accomplishes that.

Original comment by toma...@gmail.com on 18 Jun 2015 at 1:11