optimize code

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2006
Posts: 7
Reputation: Ajay Raj is an unknown quantity at this point 
Solved Threads: 0
Ajay Raj Ajay Raj is offline Offline
Newbie Poster

optimize code

 
0
  #1
Sep 28th, 2006
Hi can anny one help me out optimizing the follwing issue:
A C++ class has the following member:
int status_[75];
During performance analysis it was found out
that the class (its object) was performing unsatisfactorily
making it a necessary candidate for optimization.
The following additional information was also found out
*) Each element of the status_ array assumes only the
following 4 values: -1, 0, 1, 2
*) The bulk of the time was spent in loops like:
for(size_t i=0; i != 75; ++i) {
if(status_[i] == 1) {
// do something...
}
}
*) The set of elements of the status_ array that assume a particular
value is sparse making the above loop inefficient.
Assume that 0 is the default value.
*) The status_ array is updated at places scattered throughout the code
making it difficult to rewrite. However, a particular element
is updated only through a statement like
status[i] = -1;


Please Code an algorithm if possible

Thanks & Regards




Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 275
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: optimize code

 
0
  #2
Sep 28th, 2006
Try to write it on your own and when you have some code than we'll help you about the optimisation
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC