bpayne111 Posted March 24, 2003 Posted March 24, 2003 I have two sets of collection objects (inherit from collection base) in a project. A property in collection A, depends on the index of an object in collection B. Everything is great until items are removed from collection B because the indexes are changed and the property that depends on the index in collection B is now wrong. I can fix this programmatically many different ways. But i wonder if maybe there is a collection defined in .NET that would be of use to fixing this problem. I am not searching these collections just constantly updating properties, in loops. My best idea so far was to create an array named TrueIndex that holds the values of the real indexes an allows me to trick my program in a sense. I was considering a loop but i have graphics that depend on this and the loop would slow down everything considerably. any ideas? Quote i'm not lazy i'm just resting before i get tired.
*Gurus* divil Posted March 24, 2003 *Gurus* Posted March 24, 2003 Why would you make a property dependant on the index of something in a collection? Why not just make it dependant on the something itself? You can use the collection's IndexOf function to get the index of the something in the collection whenever you like. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
wyrd Posted March 24, 2003 Posted March 24, 2003 The best way is to probably just go into System.Collection or System.Collections.Specialized namespaces with the object browser and take a look at the different collections. That way you can look at all their functionalities and the way they work, and determine which one will best fit your current project. I'm not sure what Collection you're using (ArrayList?), but instead of removing the object perhaps you could set that location to null (c#) or nothing (vb). Not really sure how you have things set up, so just giving ideas off the top of my head here. :) Quote Gamer extraordinaire. Programmer wannabe.
philprice Posted March 25, 2003 Posted March 25, 2003 hmm, when i look at System.Collection i cant see any member objects in the object browser is this right? Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
wyrd Posted March 25, 2003 Posted March 25, 2003 Try looking under mscorlib for System.Collections mscorlib -> System.Collections in the object browser. Quote Gamer extraordinaire. Programmer wannabe.
bpayne111 Posted March 25, 2003 Author Posted March 25, 2003 well i thought about using 'nothing' but i kind of like the fact that my objects get smaller as they go... this makes the program run much faster in the long term (consider a chess engine that uses these values over and over) i've done reading on them but didn't see specialized collections i will look at specialized collections maybe that's my missing link thanks for the info Quote i'm not lazy i'm just resting before i get tired.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.