Click here to Skip to main content
15,910,603 members
Home / Discussions / C#
   

C#

 
AnswerRe: I'm Having Way Too Much Fun (but I have another question...) Pin
dan!sh 9-Dec-09 20:58
professional dan!sh 9-Dec-09 20:58 
GeneralRe: I'm Having Way Too Much Fun (but I have another question...) Pin
Roger Wright10-Dec-09 18:42
professionalRoger Wright10-Dec-09 18:42 
AnswerRe: I'm Having Way Too Much Fun (but I have another question...) Pin
PIEBALDconsult10-Dec-09 3:50
mvePIEBALDconsult10-Dec-09 3:50 
QuestionDataGridViewColumn can be accessed by multiple threads [modified] Pin
jdkulkarni9-Dec-09 18:33
jdkulkarni9-Dec-09 18:33 
Questionreg creation of multi file assembly Pin
sandhiyaus9-Dec-09 17:50
sandhiyaus9-Dec-09 17:50 
AnswerRe: reg creation of multi file assembly Pin
PIEBALDconsult9-Dec-09 18:10
mvePIEBALDconsult9-Dec-09 18:10 
QuestionTrying to use HashSet<t></t> Pin
BobInNJ9-Dec-09 13:38
BobInNJ9-Dec-09 13:38 
AnswerRe: Trying to use HashSet Pin
N a v a n e e t h9-Dec-09 14:53
N a v a n e e t h9-Dec-09 14:53 
One possible way is to enumerate the personSet and check for each person id with the expected id. Or use the extension methods like First, FirstOrDefault etc. Doing all these breaks the advantage HashSet offers and lead to O(n) complexity.

HashSet can be used only when you need to remember a value that you have already seen and when you don't care about other details about the value. Consider a scenario where you need to remove duplicates from a list. You iterate the list and add each elements to a HashSet checking Contains() before each insert. All these searches takes constant time and this makes huge difference when working with big collections.

Having said that, I think HashSet is not the right class you need. You need an associative container. Take a look at Dictionary<TKey, TValue>. Create a dictionary like Dictionary<int, Person>. Now the ids are associated with each person objects. Given an id, you can easily find the person object with a constant (O(1)) complexity.

BobInNJ wrote:
I am going to need to overload the operators == and != for the class person. My comparison
operator will return equal if and only if the classes have the same id


A recommended practice is to override Equals() and let your operator overloads call this equals. You may also need to override GetHashCode().

Smile | :)

Best wishes,
Navaneeth

QuestionDelete a word everytime the program see it. Pin
ahlm9-Dec-09 10:54
ahlm9-Dec-09 10:54 
AnswerRe: Delete a word everytime the program see it. Pin
Migounette9-Dec-09 11:56
Migounette9-Dec-09 11:56 
AnswerRe: Delete a word everytime the program see it. Pin
Abhinav S9-Dec-09 17:13
Abhinav S9-Dec-09 17:13 
GeneralRe: Delete a word everytime the program see it. Pin
ahlm9-Dec-09 18:31
ahlm9-Dec-09 18:31 
QuestionSqlCeResultSet Problem [modified] Pin
Stanciu Vlad9-Dec-09 6:25
Stanciu Vlad9-Dec-09 6:25 
AnswerRe: SqlCeResultSet Problem Pin
Migounette9-Dec-09 12:19
Migounette9-Dec-09 12:19 
QuestionRe: SqlCeResultSet Problem Pin
Stanciu Vlad9-Dec-09 20:09
Stanciu Vlad9-Dec-09 20:09 
QuestionUpdate own written TabPage Pin
Tagamoga9-Dec-09 4:18
Tagamoga9-Dec-09 4:18 
AnswerRe: Update own written TabPage Pin
The Man from U.N.C.L.E.9-Dec-09 7:01
The Man from U.N.C.L.E.9-Dec-09 7:01 
GeneralRe: Update own written TabPage Pin
Tagamoga9-Dec-09 8:28
Tagamoga9-Dec-09 8:28 
GeneralRe: Update own written TabPage Pin
The Man from U.N.C.L.E.9-Dec-09 10:18
The Man from U.N.C.L.E.9-Dec-09 10:18 
GeneralRe: Update own written TabPage Pin
Tagamoga9-Dec-09 12:24
Tagamoga9-Dec-09 12:24 
GeneralRe: Update own written TabPage Pin
The Man from U.N.C.L.E.10-Dec-09 1:27
The Man from U.N.C.L.E.10-Dec-09 1:27 
QuestionPreventing InvalidDeploymentException exceptions Pin
Jim Crafton9-Dec-09 4:16
Jim Crafton9-Dec-09 4:16 
AnswerRe: Preventing InvalidDeploymentException exceptions Pin
Paulo Zemek9-Dec-09 5:24
Paulo Zemek9-Dec-09 5:24 
GeneralRe: Preventing InvalidDeploymentException exceptions Pin
Jim Crafton9-Dec-09 5:30
Jim Crafton9-Dec-09 5:30 
AnswerRe: Preventing InvalidDeploymentException exceptions Pin
N a v a n e e t h9-Dec-09 14:58
N a v a n e e t h9-Dec-09 14:58 

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.