Re: Performance of element access in Vector



On Jan 22, 5:01 am, Georg Bauhaus <rm.dash-bauh...@xxxxxxxxxxxxx>
wrote:
george.p...@xxxxxxxxx schrieb:

If you just try to get away from C++ paradigm you can find other ways
to address these issues with raw arrays.  Think in functional
programming framework for a change.

I'm curious.  Vector algorithms use the STL paradigm specifically,
rather than some C++ paradigm.  The STL with its generic algorithms
has a Scheme history (and an Ada one).  FP languages tend to start
from sequential access to data, using recursion on the tail of some
list as their model.  The STL notions of ::iterator and
::reverse_iterator, in particular considering their const variants,
suggest the same, to me at least.  So I have two questions:

1) How does straight forward STL iteration differ from
FP recursion on lists? (Only thing I can think of is
that non-pure languages can use destructive update
of array components, so to speak (tampering in some Ada sense).)

2) Can we rely on pure FPL style compilation techniques
(as if there were neither refs nor monads) to achieve
compact representation of lists/arrays in memory,
and little copying?
(I am assuming that memory use is an important criterion
when targetting small capacity hardware.)

The issue raised by Maciej was about reading arrays of a-priory
unknown size. That will be impossible with C/C++ arrays (not
vector<>). I was trying to say that the elements of FP may be helpful
and Ada allows to use elements of FP with native array operations.
Trying to apply these technique to everything will be impractical.

G.
.



Relevant Pages

  • Re: Clean code vs. efficiency
    ... > instead of character arrays. ... The default STL ... In general, the STL containers are extremely fast, and might be faster than ... The STL allocators let you use pool allocators, but you can also that by ...
    (comp.lang.cpp)
  • Re: Compiler and an interpreter
    ... > Arrays are not more efficient than lists. ... > You should study the STL... ... For really complicate formulae, OCaml will be ...
    (comp.programming)
  • Re: AND-Problem
    ... Und STL hat noch eine Menge Algorithmen die Dir helfen können. ... Ich habe zwei Arrays, pattern1 und pattern2 sowie zwei Integers ... aktuell gueltigen Elemente in den Arrays pattern1 und pattern2 an ... wie viele Bits geloescht oder gesetzt sind in den Bitstreams, ...
    (microsoft.public.de.vc)
  • Re: Must we use Linked lists?
    ... 'Arrays of objects' is what I meant. ... David, can you suggest me a good and clear C++ book for STL ... ... You don't really need to know much about the STL just to use std::vector as a resizable array. ... I would say that right now what you need is a good introductory book on C++. ...
    (microsoft.public.vc.language)
  • Re: Performance tuning
    ... implemented heuristics on algorithms to speed things up; ... on arrays - like sorting, but also like filtering, array ... I find it funny that switch uses a dictionary, ... then performance tuning for the sake of performance tuning ...
    (microsoft.public.dotnet.languages.csharp)