Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
GeneralRe: SecuGen SDK Pin
Member 1069240123-Aug-14 1:30
Member 1069240123-Aug-14 1:30 
GeneralRe: SecuGen SDK Pin
Member 1069240123-Aug-14 1:51
Member 1069240123-Aug-14 1:51 
AnswerRe: SecuGen SDK Pin
Ravi Bhavnani23-Aug-14 17:17
professionalRavi Bhavnani23-Aug-14 17:17 
GeneralRe: SecuGen SDK Pin
Member 1069240125-Aug-14 1:53
Member 1069240125-Aug-14 1:53 
Questioncode for how to check if a file is encrypted in c# Pin
bandayashoda22-Aug-14 3:11
bandayashoda22-Aug-14 3:11 
AnswerRe: code for how to check if a file is encrypted in c# Pin
Richard MacCutchan22-Aug-14 3:17
mveRichard MacCutchan22-Aug-14 3:17 
QuestionWPF / EF & 'Audit' field updates Pin
cjb11022-Aug-14 2:40
cjb11022-Aug-14 2:40 
AnswerRe: WPF / EF & 'Audit' field updates Pin
Eddy Vluggen22-Aug-14 5:08
professionalEddy Vluggen22-Aug-14 5:08 
GeneralRe: WPF / EF & 'Audit' field updates Pin
cjb11022-Aug-14 5:27
cjb11022-Aug-14 5:27 
GeneralRe: WPF / EF & 'Audit' field updates Pin
Eddy Vluggen22-Aug-14 6:47
professionalEddy Vluggen22-Aug-14 6:47 
QuestionPlaying With Mouse Events Pin
Django_Untaken22-Aug-14 2:09
Django_Untaken22-Aug-14 2:09 
QuestionRe: Playing With Mouse Events Pin
Richard MacCutchan22-Aug-14 3:15
mveRichard MacCutchan22-Aug-14 3:15 
QuestionCreate & Download file runtime in MVC Pin
nitin_ion22-Aug-14 1:21
nitin_ion22-Aug-14 1:21 
AnswerRe: Create & Download file runtime in MVC Pin
Nathan Minier22-Aug-14 4:42
professionalNathan Minier22-Aug-14 4:42 
QuestionVS2010 crashes When Designer View Opens Pin
AmbiguousName21-Aug-14 20:43
AmbiguousName21-Aug-14 20:43 
AnswerRe: VS2010 crashes When Designer View Opens Pin
Bernhard Hiller21-Aug-14 21:27
Bernhard Hiller21-Aug-14 21:27 
GeneralRe: VS2010 crashes When Designer View Opens Pin
AmbiguousName21-Aug-14 22:24
AmbiguousName21-Aug-14 22:24 
GeneralRe: VS2010 crashes When Designer View Opens Pin
Rob Philpott22-Aug-14 0:05
Rob Philpott22-Aug-14 0:05 
QuestionDictionary<K,V> performance based on Key Type Pin
SledgeHammer0121-Aug-14 18:29
SledgeHammer0121-Aug-14 18:29 
AnswerRe: Dictionary<K,V> performance based on Key Type Pin
Matty2221-Aug-14 18:42
Matty2221-Aug-14 18:42 
GeneralRe: Dictionary<K,V> performance based on Key Type Pin
SledgeHammer0121-Aug-14 19:07
SledgeHammer0121-Aug-14 19:07 
GeneralRe: Dictionary<K,V> performance based on Key Type Pin
Matty2221-Aug-14 19:11
Matty2221-Aug-14 19:11 
AnswerRe: Dictionary<K,V> performance based on Key Type Pin
Matty2221-Aug-14 19:18
Matty2221-Aug-14 19:18 
GeneralRe: Dictionary<K,V> performance based on Key Type Pin
SledgeHammer0121-Aug-14 19:53
SledgeHammer0121-Aug-14 19:53 
I just did:

Dictionary<int, string=""> dict = new Dictionary<int, string="">();

dict[5] = "Test";

DateTime dt = DateTime.Now;

for (int i = 0; i < 1000000; i++)
{
// 10ms - int x string
string s;
dict.TryGetValue(5, out s);
}

System.Diagnostics.Debug.WriteLine((DateTime.Now - dt).TotalMilliseconds);

It's really that simple. I know that's only 1 key, so my mileage may vary with a bunch of keys. I tried that same thing with various types to get the benchmarks I originally posted.

HOWEVER, I had a brilliant break through haha. Would something like this work?

Dictionary<int, string=""> dict;

struct _Key
{
Type type;
string str;
}

Now, instead of overriding the GetHashCode and IsEquals, I just have a method:

public int GetKey(string s, Type t)
{
return s.GetHashCode() ^ t.GetHashCode();
}

whenever I want to insert a new object, I call GetKey() on it and use that as the key?

As I'm typing this, I'm beginning to poke holes in this idea... there would be no way to retrieve the string and type as I would just be keying off the hash code.

I'm also wondering if it would be possible to get two s and t combinations that produce the same key? Theoretically, I'm assuming the .net hash functions are strong. Although since I wouldn't be inserting the _Key struct into the list (and thus not override the IsEqual(), the dictionary wouldn't know for sure it was grabbing the right one...

If I do it "right" and insert the _Key, that's 60ms... better then 120ms or 590ms I guess.
GeneralRe: Dictionary<K,V> performance based on Key Type Pin
Matty2221-Aug-14 19:58
Matty2221-Aug-14 19: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.