J
jehugaleahsa
Hello:
This is probably more of an algorithms question than a C# question.
We have these classes that represent lines on a report. They contain
two field:
1) Line Print - A String that indicates the type of line and ordered
lexicographically.
2) ModCode - A String that indicates that a special action should be
taken on the line.
Since Line Print is the order that the lines are calculated and
displayed, I have a List<Line> sorted by Line Print. However, the
existing code commonly searches for all lines with a given mod code.
To do this, however, requires a linear search.
I can use binary search to find a line print, no problem. However, I
want to eliminate the common occurence of linear searches for multiple
mod codes.
First of all, is it a bad to have all these linear searches? Supposing
it is, what is the overhead of storing the Lines in both a List and a
Dictionary<string, List<Line>> going to mean for performance?
Performance does matter, here. Sure, my search times would decrease,
but I am afraid the extra memory could be problematic as well.
Suggestions?
This is probably more of an algorithms question than a C# question.
We have these classes that represent lines on a report. They contain
two field:
1) Line Print - A String that indicates the type of line and ordered
lexicographically.
2) ModCode - A String that indicates that a special action should be
taken on the line.
Since Line Print is the order that the lines are calculated and
displayed, I have a List<Line> sorted by Line Print. However, the
existing code commonly searches for all lines with a given mod code.
To do this, however, requires a linear search.
I can use binary search to find a line print, no problem. However, I
want to eliminate the common occurence of linear searches for multiple
mod codes.
First of all, is it a bad to have all these linear searches? Supposing
it is, what is the overhead of storing the Lines in both a List and a
Dictionary<string, List<Line>> going to mean for performance?
Performance does matter, here. Sure, my search times would decrease,
but I am afraid the extra memory could be problematic as well.
Suggestions?