Mutually exclusive item filtering-comparing
Mutually exclusive item filtering-comparing
- Subject: Mutually exclusive item filtering-comparing
- From: Chris Paveglio <email@hidden>
- Date: Tue, 05 Nov 2013 10:17:35 -0800 (PST)
What is the most efficient way to compare a list of mutually exclusive items? I know this isn't exactly Cocoa/iOS specific. I have a table that needs to disable certain rows based on what other rows are selected.
I have several objects, let's say "weapons in a game". Such as a bow and arrow, a rifle, a bazooka.
A character can use any of the objects, but some can't be used together. A bazooka is too big and requires 2 hands to carry so you can't select both a bazooka and rifle at the same time. You can select bow & arrow and rifle, but if you select both of those, you can't take the bazooka too. I hope you get the idea.
My exclusions array has many simple objects. Each object has 3 ivars- (int)itemID1, (int)itemID2, (string)isMutuallyExclusive (not my design but could be changed if there is a better way).
The idea I have is whenever a row is selected, I will take the itemID of that item, then iterate with every other itemID in the table- then I do an iteration on every object in the exclusions array. If the selected row itemID is in the exclusion object, and current row itemID being compared are both in the exclusion object, I can get it's exclusion (non-exclusive items won't be in the list).
So, repeat with 100 items in the table, each table row comparing against the exclusion list which has over 100 entries. It could result in up to 10,000 comparisons getting tested until the exclusion is found or exhausted.
It seems extremely process intensive. Is there a better way, or some basic concept I might be missing?
Thanks,
Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden