473,396 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Indexing array...

I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:

for a given pointer p, p[0] contains an address and p[1] an offset.
I must return the content of the address plus the offset.. Which way
is faster and more portable?

1.- *( ((unsigned int*)*p) + *(p+1) ) ;
2.- ((unsigned int*)*p)[ *(p+1) ] ;
3.- *((unsigned int*)(*p ++ + *p)) ;

thanks!

Jul 18 '07 #1
5 1574
On Wednesday 18 Jul 2007 6:51 pm, in comp.lang.c, di****@gmail.com <
di****@gmail.comwrote:
Message ID: <11*********************@z24g2000prh.googlegroups. com>
I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:

for a given pointer p, p[0] contains an address and p[1] an offset.
I must return the content of the address plus the offset.. Which
way is faster and more portable?

1.- *( ((unsigned int*)*p) + *(p+1) ) ;
2.- ((unsigned int*)*p)[ *(p+1) ] ;
3.- *((unsigned int*)(*p ++ + *p)) ;
In message:
<11**********************@g37g2000prf.googlegroups .com>

You asked exactly the same question and received three responses.
What was wrong with them?
Jul 18 '07 #2
Op Wed, 18 Jul 2007 18:56:41 +0530 schreef santosh:
On Wednesday 18 Jul 2007 6:51 pm, in comp.lang.c, di****@gmail.com <
di****@gmail.comwrote:
Message ID: <11*********************@z24g2000prh.googlegroups. com>
>I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:

for a given pointer p, p[0] contains an address and p[1] an offset.
I must return the content of the address plus the offset.. Which
way is faster and more portable?

1.- *( ((unsigned int*)*p) + *(p+1) ) ;
2.- ((unsigned int*)*p)[ *(p+1) ] ;
3.- *((unsigned int*)(*p ++ + *p)) ;

In message:
<11**********************@g37g2000prf.googlegroups .com>

You asked exactly the same question and received three responses.
What was wrong with them?
Perhaps (in fact ;-) he used google groups. They don't show his two, not
yours or the three answers.
--
Coos, using usenet and a newreader
Jul 18 '07 #3
santosh wrote:
On Wednesday 18 Jul 2007 6:51 pm, in comp.lang.c, di****@gmail.com <
di****@gmail.comwrote:
Message ID: <11*********************@z24g2000prh.googlegroups. com>
I hope this is the correct group. It came out a doubt about speed
when indexing an array in the following way:
You asked exactly the same question and received three responses.
What was wrong with them?
Google Groups was broken again yesterday, posts were not getting out to
their users.

Brian
Jul 18 '07 #4
Perhaps (in fact ;-) he used google groups. They don't show his two, not
yours or the three answers.
yeah... google groups, you are right. If you have any free usenet
server to be used to
read news I would appreciate it a lot.

Jul 19 '07 #5
On Thursday 19 Jul 2007 4:35 pm, di****@gmail.com <
di****@gmail.comwrote in message
<11*********************@n60g2000hse.googlegroups. com>:
>Perhaps (in fact ;-) he used google groups. They don't show his
two, not yours or the three answers.

yeah... google groups, you are right. If you have any free usenet
server to be used to
read news I would appreciate it a lot.
nntp.aioe.org
or
news.aioe.org

also

news.gmane.org

Jul 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Hilde Roth | last post by:
This may have been asked before but I can't find it. If I have a rectangular list of lists, say, l = ,,], is there a handy syntax for retrieving the ith item of every sublist? I know about for i...
6
by: Michael Drumheller | last post by:
(If you're not interested in NumArray, please skip this message.) I am new to NumArray and I wonder if someone can help me with array-indexing. Here's the basic situation: Given a rank-2 array...
1
by: jon wayne | last post by:
Hi Am trying to replace the classic switch case construct (am workng on a telecom stack devlpmnt)with an array of function ptrs. The problm am facing is that of indexing. - the case vals can be...
10
by: Tamir Khason | last post by:
I have a pointer to array and I want to apply indexing to this Array so I have function (name it IntPrt Func) to go to certain member I can use (as C++) Func, but in C# I recieve an error "Cannot...
0
by: Chung Leong | last post by:
Here's a short tutorial on how to the OLE-DB extension to access Windows Indexing Service. Impress your office-mates with a powerful full-text search feature on your intranet. It's easier than you...
26
by: jacob navia | last post by:
Suppose an implementation where sizeof int == 4 sizeof void * == 8 sizeof long long == 8 When indexing an array array this would mean that arrays are limited to 2GB. To overcome this,
4
by: Grace Fang | last post by:
Hi, I am writing code to sort the columns according to the sum of each column. The dataset is huge (50k rows x 300k cols), so i need to read line by line and do the summation to avoid the...
4
by: Emin | last post by:
Dear Experts, How much slower is dict indexing vs. list indexing (or indexing into a numpy array)? I realize that looking up a value in a dict should be constant time, but does anyone have a...
4
by: Chiefy | last post by:
C# APP Basically i am trying to use indexing on an array that i have fed into a method as its parameter. Here is a simplified version of my code. public void Inputs(string path) { ...
3
by: Rüdiger Werner | last post by:
Hello! Out of curiosity and to learn a little bit about the numpy package i've tryed to implement a vectorised version of the 'Sieve of Zakiya'. While the code itself works fine it is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.