Hi, I'm just starting out with obj-c and I've got an idea for a project that requires a fairly odd storage structure and I'd like advice on how to implement it. The real question Is this an object I should be creating with malloc/free and pointers or is it doable with object oriented storage facilities like NSArray and Hashtables? Also, ideas about how to actually do it are welcome.
I guess this would be the model for the program. Here's what it needs to do:
- Store many 2D segment objects (X1,Y1,X2,Y2)
- Each segment has one associated integer property. (think brightness?)
- No two segments can have the same 4 coordinates.
- have a method to quickly look up all the segments that have the same X1,Y1.
- have a method to quickly look up all the segments that have the same X1.
- have a method to quickly look up all the segments that have the same X2,Y2.
- have a method to return all segments.
- In practice there can be hundreds or possibly a thousand segments.
- The size of the space/canvas or whatever needs to be resizable. (Meaning a 1D array representing a n-D array might be inefficient)
- Maximally the dimensions of the canvas will be 128x512. This would be a very extreme case.
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. Also, There's no 2D array in obj-c.
Thanks for your time,
-Matt
0 comments:
Post a Comment