I am writing a chess program that stores all the pieces in an NSMutableArray
with [NSNull null]
representing empty spaces. I just found out about NSPointerArray
and was wondering if I should switch over to that instead. Basically, what are the pros/cons of using an NSMutableArray
with [NSNull null]
values vs an NSPointerArray
?
Asked
Active
Viewed 452 times
2
-
You might consider for example downloading the Gnu Chess source code. Usually people use 64 bit unsigned integers to represent some attribute of a chess board, for example one 64 bit unsigned integer representing all occupied fields, all fields occupied by pawns, black or white pieces etc. That way, many operations that are needed during the evaluation of a position turn into single assembler instructions. At the very least, there is no reason at all for the representation of pieces as Objective-C objects. – gnasher729 Apr 23 '14 at 16:51
-
The problem is that I am doing variable chess board sizes (for chess variants) a 64-bit number wouldn't work for every board. – aeubanks Jun 06 '14 at 04:10
1 Answers
0
If you are putting objects in the NSMutableArray
as well, say the chess pieces, stay with NSMutableArray
. Also there is really no reason not to use [NSNull null]
, really not much different that putting a NULL in a NSPointerArray
.
If you are concerned about performance measure before making any change.

zaph
- 111,848
- 21
- 189
- 228