Hi, I'm just starting out with obj-c and I've got an idea for a project that uses a fairly odd storage structure and I'd like advice on how to implement it.
So here's what I need to do:
•Store many 2D segments (X1,Y1,X2,Y2)
•Each line has one or more associated integer properties
•No two lines can have the same 4 coordinates.
•frequently and quickly look up all the lines that have the same X1,Y1.
•frequently and quickly look up all the lines that have the same X1.
•frequently and quickly look up all the lines that have the same X2,Y2.
•The size of the space/canvas or whatever needs to be resizable. (Meaning a 1D array representing a 2D array might be inefficient)
•In practice there can be hundreds or possibly a thousand lines.
Is this something I should be creating with malloc/free and pointers or is it doable with object oriented storage facilities like NSArray and Hashtables?
I've done this in the past and I've used a 2D array representing the X1,Y1 space and then filled cell in that 2D array with a hashtable full of X2,Y2,Value objects. This has been passable but leaves much to be desired.
I just want to be clear. I'm aware that it's possible to do this both with C and ObjC strategies. I'm just wondering if it would be smarter to revert back to C in such a complicated instance.
Page 1 of 1
0 Replies - 29361 Views - Last Post: 07 March 2013 - 04:35 PM
Page 1 of 1