Click here to Skip to main content
15,895,256 members
Home / Discussions / C#
   

C#

 
GeneralRe: not-null-field issue Pin
newbieAl10-Sep-07 8:00
newbieAl10-Sep-07 8:00 
GeneralRe: not-null-field issue Pin
Elina Blank10-Sep-07 8:46
sitebuilderElina Blank10-Sep-07 8:46 
GeneralRe: not-null-field issue Pin
kboyette10-Sep-07 8:54
kboyette10-Sep-07 8:54 
GeneralRe: not-null-field issue Pin
newbieAl10-Sep-07 9:18
newbieAl10-Sep-07 9:18 
GeneralRe: not-null-field issue Pin
kboyette10-Sep-07 9:53
kboyette10-Sep-07 9:53 
GeneralRe: not-null-field issue Pin
newbieAl10-Sep-07 10:24
newbieAl10-Sep-07 10:24 
GeneralRe: not-null-field issue Pin
kboyette10-Sep-07 12:01
kboyette10-Sep-07 12:01 
GeneralRe: not-null-field issue Pin
newbieAl11-Sep-07 2:24
newbieAl11-Sep-07 2:24 
GeneralRe: not-null-field issue Pin
newbieAl10-Sep-07 9:07
newbieAl10-Sep-07 9:07 
QuestionWeb Browser control speed&threading Pin
Spacix One10-Sep-07 7:01
Spacix One10-Sep-07 7:01 
Questionnext cell on DataGridView ? Pin
KreaA10-Sep-07 6:05
KreaA10-Sep-07 6:05 
Questionstatic fields for threads in c# Pin
mr.mohsen10-Sep-07 5:04
mr.mohsen10-Sep-07 5:04 
AnswerRe: static fields for threads in c# Pin
PIEBALDconsult10-Sep-07 5:20
mvePIEBALDconsult10-Sep-07 5:20 
AnswerRe: static fields for threads in c# Pin
Luc Pattyn10-Sep-07 5:38
sitebuilderLuc Pattyn10-Sep-07 5:38 
QuestionHttpWebRequest Pin
smsmfe10-Sep-07 4:54
smsmfe10-Sep-07 4:54 
AnswerRe: HttpWebRequest Pin
led mike10-Sep-07 5:23
led mike10-Sep-07 5:23 
QuestionPath stripping algorithim.....help required Pin
c#_keithy10-Sep-07 4:37
c#_keithy10-Sep-07 4:37 
AnswerRe: Path stripping algorithim.....help required Pin
Judah Gabriel Himango10-Sep-07 4:59
sponsorJudah Gabriel Himango10-Sep-07 4:59 
AnswerRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 5:15
Skippums10-Sep-07 5:15 
GeneralRe: Path stripping algorithim.....help required Pin
c#_keithy10-Sep-07 5:43
c#_keithy10-Sep-07 5:43 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 5:48
Skippums10-Sep-07 5:48 
GeneralRe: Path stripping algorithim.....help required Pin
Guffa10-Sep-07 6:04
Guffa10-Sep-07 6:04 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 7:06
Skippums10-Sep-07 7:06 
AnswerRe: Path stripping algorithim.....help required Pin
Luc Pattyn10-Sep-07 7:12
sitebuilderLuc Pattyn10-Sep-07 7:12 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 8:22
Skippums10-Sep-07 8:22 
I don't think that this algorithm will be faster in most cases. Here is why I think so:

1. The StartsWith will compare at most the length of common, but at least as much as the length of the match

2. LastIndexOf will compare the difference between the current guess at the common string and the next guess at the common string

3. Taking the substring will require the length of common to copy.

So the only time that I can think of where this algorithm would save time would be if you have two non-matching directories that start identically, such as "Food for thought" and "Food for thomas", and those are the ONLY directories you are comparing. Assuming that this is not the case (typical, since there are thousands of entries), the other way cuts out the expenses from parts 2 and 3. The other issue that I see with this is that if you have 3500 paths, and the first 200 fall into a directory that is NOT going to end up as the common directory, you spend a lot of extra time being told that these directories in fact do match a directory that doesn't matter. I also think that directory names in windows are case-sensitive, so the suggestion on making the comparison case-insensitive is unnecessary and takes more time (since you have to then convert the chars to lowercase). One thing that I do like is the suggestion to compare the first and last if they are already sorted (doubtful since you don't already know the common directory). The assumption made as to the efficiency of this algorithm also depends on the collection being "roughly" sorted, that is that the first and last directories differ significantly, which will reduce the amount of time wasted on using "StartsWith". Anyway, those are the reasons that I would stick with the other algorithm myself.

Jeff

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.