home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!amorgan
- From: amorgan@Xenon.Stanford.EDU (Crunchy Frog)
- Subject: Re: array element swap help
- Message-ID: <1992Jul30.185540.10776@CSD-NewsHost.Stanford.EDU>
- Sender: news@CSD-NewsHost.Stanford.EDU
- Organization: Computer Science Department, Stanford University.
- References: <1992Jul30.161648.26055@news.iastate.edu>
- Date: Thu, 30 Jul 1992 18:55:40 GMT
- Lines: 28
-
- In article <1992Jul30.161648.26055@news.iastate.edu>
- raeker@tc4.fi.ameslab.gov (Todd J. Raeker) writes:
- >I need to swap values in an array while sorting it, currently I am doing
- >the swap as follows
- >
- >
- > temp = ztmp[j];
- > ztmp[j] = ztmp[k];
- > ztmp[k] = temp;
- >
- >
- >This is currently a bottleneck in my program and I need to figure a
- >better way to do due this. Since I am not an advanced c programmer, this
- >is the best I could come up with, is there a more efficient way?
-
- *This* is the bottleneck in your code? Are you sure about that (okay,
- if you are sorting on disk or the array is of huge structures
- then I can believe it, and there are ways to speed that up)? If
- this is just a simple array of int/float/double/etc then I am very
- surprised. What makes you think that this is the bottleneck?
-
- >Dr. Todd J. Raeker | 307B Wilhelm Hall
-
- Oh, there is no real way to speed this up (and if anyone starts the XOR
- thread again they are going to be in big trouble), what you are doing
- is correct.
-
- C Frog
-