c# - Finding conflicts within lists -
i have problem logic , mapping 2 different tables. 1 table presented user them select items from. need map selections bigger list of scheme recognized items. scheme items combinations of user items.
user items = key | item 1 | 2 | b 3 | c 4 | d 5 | e 6 | f
system items = systemcode | useritemsmapping eg1 | 1 eg2 | 2 eg3 | 1,2 eg4 | 1,3 eg5 | 2,3 eg6 | 4 eg7 | 5 eg8 | 5,6 eg9 | 3 eg10| 4,5,6 if user enters a, b, c, d, e, f [= 1, 2, 3, 4, 5, 6 in keys] input. scheme should able determine conflicting mappings. selected items a, b & c in conflict, please select following: eg3 (1,2) + eg9 (3) or eg4 (1,3) + eg2 (2) or eg5 (2,3) + eg1 (1) selected items d, e & f in conflict, please select following: eg8 (5,6) + eg6 (4) or eg10 (4,5,6)
this done in c# using lists , custom classes table contents, e,g list , list.
edit: i've managed this: 1) scheme codes has of user items in it. 2) scheme codes have more user item goes 1 list. combo codes goes another. 3) loop through combos list , if user item in against more 1 scheme code add together conflict list.
so have list of conflicts this:
[code]
public class conflictsets { public list<systemcodes> systemcodeslist {set; get;} public list<int> usercodeslist {set; get;} } public class systemcodes { public string code {set; get;} public string useritems {set; get;} } [/code]
the problem list conflictsetslist has pairs of conflicts in it. above example: conflictsetslist[0].systemcodeslist[0] = eg3 conflictsetslist[0].systemcodeslist[1] = eg4 conflictsetslist[1].systemcodeslist[0] = eg3 conflictsetslist[1].systemcodeslist[1] = eg5 conflictsetslist[2].systemcodeslist[0] = eg4 conflictsetslist[2].systemcodeslist[1] = eg5
what want class has this: conflictsetslist[0].options[0].systemcodeslist[0] = eg3 conflictsetslist[0].options[0].systemcodeslist[1] = eg9 conflictsetslist[0].options[1].systemcodeslist[0] = eg4 conflictsetslist[0].options[1].systemcodeslist[1] = eg2 conflictsetslist[0].options[2].systemcodeslist[0] = eg5 conflictsetslist[0].options[2].systemcodeslist[1] = eg1
does create more sense? sorry i'm not @ explaining this.
this info coming these inputs: dtsystemcodes = new datatable. row["userinputkeys"] = xx|yy dtuseritems = new datatable. row["key"] = xx list inkeys = new list() { 1, 2, 3, 4, 5, 6 };
thank you.
easiest solution create 2d bool array mappings of lenght of [1 + 2^number of examples,number of examples]
valid eg1 eg2 eg3 ... eg10 0 0 0 0 0 1 0 0 0 1 ... 1 1 1 1 1 (0=false,1=true) in loop test each row validity , set results in fisrt column in fisrt column have list of possible mapping shemes
c#
No comments:
Post a Comment