• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArray vs. embedded loop in C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray vs. embedded loop in C?


  • Subject: Re: NSArray vs. embedded loop in C?
  • From: Michèle Garoche <email@hidden>
  • Date: Mon, 5 Aug 2002 23:05:24 +0200

Hello Tim,

To be more precise, I'm using it for a calculator: either to find the string representation of the number entered by the user when he changes the base or to add the range(s) of buttons (the digits are entered by clicking buttons: 1, 2, ...) needed for a given base when the user adds or removes a base.

Once a "special base" is used - I mean other than those well handled by the compiler - I have to access the array each time a digit is entered by the user.

Is it considered as frequent access?

Cheers,
Michhle

It is almost impossible to know what is best without knowing what you are doing with the array. How often are you accessing it? randomly, or sequentially? If the access is infrequent enough, you could consider using a static function call (even inline it for that matter), such as:

char DigitRep(int radix, int digit) {
return (digit > 9) ? '17' + digit : '0' + digit;
}

Cheers,
tim

Hello,

I need to build an array of strings corresponding to the representation of digits in any base allowed by the compiler.

This array will be used in two places.

At the moment, the array is written in C and duplicated in both places:

// Build the representation
int i = 0;
char repr[myRadix];
while (i < myRadix)
{
repr[i] = (i > 9) ? '17' + i : '0' + i;
i++;
}

Would it be better to use an NSArray and no duplicate?

Michhle
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSArray vs. embedded loop in C?
      • From: Ondra Cada <email@hidden>
References: 
 >Re: NSArray vs. embedded loop in C? (From: Timothy Ritchey <email@hidden>)

  • Prev by Date: Re: NSArray vs. embedded loop in C?
  • Next by Date: Accessor methods and (auto)release: conclusion
  • Previous by thread: Re: NSArray vs. embedded loop in C?
  • Next by thread: Re: NSArray vs. embedded loop in C?
  • Index(es):
    • Date
    • Thread