If I create an NSMutableArray that might have up to 2^16 elements, but will mostly be empty, will I be wasting space or is NSMutableArray implemented as a sparse array?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Elements in an
NSArraycan’t be empty and there’s no “default” value. To representnil, you’d usually use the singleton[NSNull null], which is still a reference to an object so it consumes memory (the pointer). I’d consider usingNSDictionary(orNSMutableDictionary) with numeric (NSNumber) keys instead.