DesignMatrix
last edited September 8, 2005 11:47:45 (67.42.7.239)
| |
|---|---|
| Edit / History / New / Search | Quick Links: Home / Recent Changes / Glossary / Jobs / Forums / Help |
|
Object Design: Matrix collection class
DesignCollection:Collection types - More general than an array, more efficient than a dictionary.
Why a Matrix is not an Array or a Dictionary An array (NSArray;DesignArray) is a one-dimensional structure: it takes a single coordinate to refer to a single object. For any sane computer program, this is sufficient as there can only be a finite number of objects anyway. But it is convenient to use something a little more general.
Apple's answer is NSDictionary (DesignDictionary) - a class that stores objects and refers to them by arbitrary objects, not simple numbers. The very existence of this storage type is intrinsic to all of Cocoa, and weaved into every class you write: the This occurs both because any object can be a key in any array, and because only one hashing algorithm can be used for each type. So we need a new storage type to fill the void, one I have christened (for now) the Matrix Design. This:
Advantages:
Disadvantages:
What do people think of my criterion for and assessment of the Matrix design? Feel free to add to the advantages/disadvantages lists and add any other comments -- KritTer
The design in practice: KTMatrix [http://www.geocities.com/kritter_cocoadev/KTMatrix/] I am designing a matrix class (as you may have guessed from ClassClusters), and would appreciate some input. It implements the design above, using dictionaries for keys, and arbitrary hashing objects to turn them into integer hash values (which are then used as keys in a storage dictionary). To simplify its use in the role it was intended (cuboid multi-dimensional arrays), it has in-built functionality for easier syntax in those areas, to the point where the equivalent of is
and the equivalent of
is
Does anyone have any input on this matter? Compliments, comments, insults and directions to code that already does something similar all welcome. I really want to design this thing well if there is interest, so don't be shy. -- KritTer
Issues discovered (and, hopefully, comments)
General comments so far... I am very interested in this. As it happens, it popped up at basically the exact moment that it might be useful to me. Serendipity! Anyhow, I suspect that others will be interested also. As an aside, does anybody know when the MiscKit is going to release something for OS X? KritTer's matrix class sounds like it might fit nicely into the MiscKit, but they haven't released anything in quite a while. If all else fails, a CocoaDev framework might be an option... -- RobRix
Although I don't think I have any time to devote to beta testing, I will eagerly await the outcome of this project. It seems like a Cool Thing. -- DavidRemahl
Ahh... I'd beta test if I could, but outside using it in a program I'm making, I'm probably not going to have enough time, sorry : 23 -init... methods? That beats my record. -- RobRix Even that would be great. With that many inits, I'd spend days checking it all :( -- KritTer Okie dokie. I gotta learn to use F-Script and ObjCUnit and those sorts of things... -- RobRix
OK, I know I'm being naive or something. I've looked through KTMutableMatrixes? documentation but I still don't get it. If you send one of the matrix: messages to get a matrix and store it in a
it seems you have to declare cuboid bounds. If you do, then, and only declare, say 3,4,2, and access 3,4,3, will an error happen and if so, how do you "add" to it's bounds? I'm confused. KTMutableMatrix seems almost the same as KTMatrix. Help?
KritTer's updates:
I have a quick question: wouldn't
Work? Now that I think about it, you might not even need NSArray for static arrays. Wow. | |
| Edit / History / New / Search | Quick Links: Home / Recent Changes / Glossary / Jobs / Forums / Help |