Re: Reversing Array Elements?



glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

steve <kargls@xxxxxxxxxxx> wrote:

< So, for the pointer p, the compiler sets up a dope vector
< and 'points' the first element of p at the last element of
< a.

So it doesn't actually reverse the array.

Depends what you mean by "actually reverse the array". It is an array.
It has the elements in reverse order. It doesn't force making a copy of
the array stored in a reverse memory layout; I assume that's what you
mean by "actually reverse the array".

That is a fairly low-level implementation-oriented view (not surprising)
rather than a specification of the language. The language specification
is deliberately more abstract than that. As a result, it gets hard to
absolutely guarantee much of anything at that level. The best one can do
is describe typical or easy implementations. An implementation certainly
could make such a reordered copy in physical memory as an optimization.
In fact, if you pass such an array as an actual argument to an
explicit-shape or assumed-size dummy, it very likely would result in a
copy reordered in physical memory. So would assignment.

While I'm no expert (at al) on IDL, I'd guess that the same was true
there - that you don't have a guarantee that the operation in question
causes a physically reversed copy in memory.

And for that most part, I'd guess that one would not and should not
care. There are legitimate questions relating to performance. But that's
a separate question from the one of whether the language defines the
operation. See Michael's comment:

but I have no idea how (in)effecient that is.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: Working with floating point numbers.
    ... mechanism but now need to reverse the situation and convert a double to the ... I have reversed the code but come stuck when I try to assign the array to ... I've tried to Asc) the string but it didn't work and when I ... Dim S As MyStrings ...
    (microsoft.public.access.modulesdaovba)
  • Re: reverse a collection
    ... indirectly you can leverage this method. ... similar methods, then you are correct, looping may be your only option. ... Array has a reverse method. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Cohens paper on byte order
    ... > you changed from a bit sequence to what appears to be ... an array of unsigned char to represent a bit array, ... in the reverse order instead? ... But the user input IS at the beginning a bit array ...
    (sci.crypt)
  • Re: How to open a file from the end and read the last 100 lines
    ... > I agree CPAN is great. ... #read the file - in reverse - into an array ... messages file. ...
    (comp.lang.perl.misc)
  • Re: Maximum Array int is 330 M, not 2.1 billion
    ... I simply filled an array of this size with ints...I got as far as 320 ... What is relevant is the address space limit of your application, which happens to be 2 GiB on 32-bit Windows, which happens to be the maximum value of a signed 32-bit int as well -- but this is coincidental. ... You can make Windows run with a 3 GiB virtual address space for each application, for example, and 64-bit applications have a unfathomably bigger limit that I can't recall right now, but you'll hit the limits of your physical memory far sooner than that. ... There is no extra per-element overhead for managed arrays. ...
    (microsoft.public.dotnet.languages.csharp)