Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
GeneralList compare algorithm Pin
Stevo Z27-Mar-08 2:03
Stevo Z27-Mar-08 2:03 
GeneralRe: List compare algorithm Pin
Pete O'Hanlon27-Mar-08 2:23
mvePete O'Hanlon27-Mar-08 2:23 
GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 3:02
Stevo Z27-Mar-08 3:02 
GeneralRe: List compare algorithm Pin
carbon_golem27-Mar-08 3:43
carbon_golem27-Mar-08 3:43 
GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 3:58
Stevo Z27-Mar-08 3:58 
GeneralRe: List compare algorithm Pin
carbon_golem27-Mar-08 4:22
carbon_golem27-Mar-08 4:22 
GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 4:26
Stevo Z27-Mar-08 4:26 
GeneralRe: List compare algorithm Pin
carbon_golem27-Mar-08 4:42
carbon_golem27-Mar-08 4:42 
[0, 20][20, 0] have the same sum, but aren't close... but if they have the same sum, they could be the same. you know for a fact that if 2 points do not have the same sum, then they aren't ever going to be equivalent. Now, knowing that, if you sort on the sum of the two you would have that to use also. So the sums, would be ascending ala..
List A:[1][2][3][3][3][4][5][5][5][78][9000]... (Longer)
List B:[1][1][3][4][4][4][5][5][6][78][9000]... (Shorter)
What I'm saying is this.
Sort both on the sum.
Pick the shorter list to use for the base comparison.
The following code won't work, but you should get the idea from that.
This doesn't use any kind of fencepost. If it were, we'd save the index of the last matched
in the list and use that as a starting point instead of beginning at the front of the longer list.
<br />
foreach(Point a in shorter){<br />
    foreach(Point b in longer){<br />
        if(a.Sum != b.Sum) break;<br />
            if(a == b)<br />
                union.Add(a); break;<br />
    }<br />
}<br />


"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand

GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 4:57
Stevo Z27-Mar-08 4:57 
GeneralRe: List compare algorithm Pin
carbon_golem27-Mar-08 5:15
carbon_golem27-Mar-08 5:15 
GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 5:38
Stevo Z27-Mar-08 5:38 
GeneralRe: List compare algorithm Pin
carbon_golem27-Mar-08 5:52
carbon_golem27-Mar-08 5:52 
GeneralRe: List compare algorithm Pin
DavidNohejl27-Mar-08 4:51
DavidNohejl27-Mar-08 4:51 
GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 5:13
Stevo Z27-Mar-08 5:13 
GeneralRe: List compare algorithm Pin
DavidNohejl27-Mar-08 5:59
DavidNohejl27-Mar-08 5:59 
GeneralRe: List compare algorithm Pin
Stevo Z27-Mar-08 6:41
Stevo Z27-Mar-08 6:41 
QuestionChange mouse cursor when hover mouse over a DataGridView cell's border ? Pin
nesaver8527-Mar-08 1:47
nesaver8527-Mar-08 1:47 
AnswerRe: Change mouse cursor when hover mouse over a DataGridView cell's border ? Pin
Eswara Kumar2-Apr-10 2:32
Eswara Kumar2-Apr-10 2:32 
General[Message Deleted] Pin
nesaver8527-Mar-08 1:32
nesaver8527-Mar-08 1:32 
GeneralRe: Merge cells in DataGridView ? Pin
Anoop Unnikrishnan27-Mar-08 1:37
Anoop Unnikrishnan27-Mar-08 1:37 
GeneralRe: Merge cells in DataGridView ? Pin
jp2code28-Jan-10 4:58
professionaljp2code28-Jan-10 4:58 
GeneralDataTable rows Pin
NewToAspDotNet27-Mar-08 1:26
NewToAspDotNet27-Mar-08 1:26 
GeneralRe: DataTable rows Pin
Anoop Unnikrishnan27-Mar-08 1:34
Anoop Unnikrishnan27-Mar-08 1:34 
GeneralRe: DataTable rows Pin
NewToAspDotNet27-Mar-08 1:54
NewToAspDotNet27-Mar-08 1:54 
GeneralRe: DataTable rows Pin
Evan St. John27-Mar-08 9:18
Evan St. John27-Mar-08 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.