[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

More efficent looping

Asked by atomicgs12 in Algorithms, C Programming Language, C++ Programming Language

I have some code that does a while loop checking a number of values via a function. What I am looking for is a more processor efficient way to reduce the amount of code lines and to speed up the loop, machine wise, as much as possible. I was thinking of something either using a list or some kind of bitwise, and/or ing/sifting thing. The pseudo code for the loop is something like:

int arrSuccess[50]={0};
int arrStuff[50] = {0};
int PassFail=0;
int nVal1      = 18;
int nVal2      = 23;
int nVal3      = 112;
      .
      .
      .
int nVal50      = 786;

while(PassFail == 0)
{
      if(arrSuccess[0] != 1)
      {
            // if DoSomething is successful it will return a 1, failure = 0
            arrSuccess[0] = DoSomething(arrStuff[nVal1]);
      }
      .
      .
      .
      if(arrSuccess[49] != 1)
      {
              arrSuccess[0] = DoSomething(arrStuff[nVal50]);
      }

      PassFail = 1;

      for(int 1 = 0; i<50; i++)
      {
            if(arrSuccess[i] == 0)
            {
                  PassFail = 0;
                  break;
            }
      }
}

So I would like to eliminate the multiple lines for the call to the DoSomething function.

Thanks
[+][-]11/05/09 12:13 PM, ID: 25753433Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 12:19 PM, ID: 25753496Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 12:25 PM, ID: 25753565Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 01:49 PM, ID: 25754433Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 02:02 PM, ID: 25754542Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 02:04 PM, ID: 25754559Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 02:27 PM, ID: 25754789Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 04:56 PM, ID: 25755810Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 04:58 PM, ID: 25755823Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 08:22 AM, ID: 25760486Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/07/09 12:48 AM, ID: 25765483Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/09/09 06:14 PM, ID: 25781878Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/10/09 06:21 PM, ID: 25791868Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625