|
No probs. Was just making sure you're aware that release mode + no debugger can make substantial impact
on simple synthetic tests like this. But sounds like you are
I can't think of any other obvious way to improve the lookup performance further.
The inbuilt dictionary is pretty fast. It's often difficult to beat.
I've made some dictionary like structures that are faster GenericHashTrie<t> for example but they have significant downsides compared to the generic dictionary.
|
|
|
|
|
Don't use DateTime for measuring performance; use the Stopwatch class[^] instead.
As you suspect, your "breakthrough" won't work. If you use the result of GetHashCode as a key, you can incorrectly consider two different keys to be the same due to hash code collisions.
You could try making an immutable key class and caching the hash code:
sealed class _Key : IEquatable<Key>
{
private readonly string _s;
private readonly Type _t;
private readonly int _hashCode;
public _Key(string s, Type t)
{
if (s == null) throw new ArgumentNullException("s");
if (t == null) throw new ArgumentNullException("t");
_s = s;
_t = t;
unchecked
{
_hashCode = (s.GetHashCode() * 397) ^ t.GetHashCode();
}
}
public string S
{
get { return _s; }
}
public Type T
{
get { return _t; }
}
public override int GetHashCode()
{
return _hashCode;
}
public override bool Equals(object obj)
{
return Equals(obj as _Key);
}
public bool Equals(_Key other)
{
if (ReferenceEquals(other, null)) return false;
return _s == other._s && _t == other._t;
}
public static bool operator ==(_Key left, _Key right)
{
return Equals(left, right);
}
public static bool operator !=(_Key left, _Key right)
{
return !Equals(left, right);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
If you're really after performance - would it be possible not to use a dictionary at all?
Regards,
Rob Philpott.
|
|
|
|
|
Hello
I have an existing .NET application which is making use of RAPI.dll till date to sync data on windows mobile. It works in the following way.
On my .NET windows based application I have option to sync mobile. When I click on that option, my app connects to database fetches records and creates a .DAT file which will then be added to mobile with the help of RAPI.dll.
Now I was asked to make use of Microsoft Sync framework as part of architectural changes within the project, as it been used in other areas of the project. So Im just wondering to know how to get the similar functionality what we were having with RAPI.dll in our project.
Thanks in advance.
Krishna
|
|
|
|
|
krishnapnv wrote: Im just wondering to know how to get the similar functionality It probably won't work "similar". It's a complete framework, and it comes with a lot of documentation and examples[^].
You'll probably need to invest some time in those docs.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
my question is how to decode ( i dont have encoding method) :
i got these from a website :
d926ef0d-07df-3c5b-2246-12e061f71be1 ------> "0000000000"
fd7bd272-f7e8-1e57-0a82-e15b79694d25 ------> "09130000000"
146b2bf5-fddb-5e68-0e9a-e5cdd19513dc ------> "0000000001"
4fb94dee-654f-55a5-5c94-71974b23fcd4 --------> "09130000001"
b69ff890-e528-a2fc-c011-8f31dcfe4794 ----> "09125395974"
f734f107-2d2c-b2e0-ed26-b92679d7cf68 ---> ?
any decoding algorithm ?
thanks in advanced!
|
|
|
|
|
The values on the left are GUIDs and bear no relation to the values on the right. What is this information and what are you trying to achieve?
|
|
|
|
|
They look like GUIDs (they are formatted that way, but of course one can format any old garbage like that so you can't really be sure what they are). So there might not be any way to decode them. Perhaps, and this is just speculation, the strings are stored in a table and associated with a GUID when first encountered. That would mean you can't really do anything without access to that table. That's the sort of thing that's done to prevent whatever it is you want to do.
|
|
|
|
|
There may be, but more likely not.
Another possibility is that what is formatted as a GUID may simply be a 128-bit one-way hash of the value, in which case you can't "decode" it.
|
|
|
|
|
On the other hand, on the right side there are only 11-digit numbers. For 11-digit numbers, some 35 bits are sufficient (even when you encode it as ASCII characters, 88 bits are enough). If the process of generating the Guid uses that 11-digit number only (and nothing else) as an input, then a reversal of the process could be theoretically possible: no information need to be lost during that process. But that's surely not easy to find out how they did it.
|
|
|
|
|
Yes, but then the leading bits would probably be all zeroes.
|
|
|
|
|
Is it possible to have encoding method?
Thanks in advanced!
|
|
|
|
|
You are showing signs of optimism over experience: read the answers you have already, and try to think about what they are telling you.
I will summarize them for you:
Those look like GUID or Hash objects: neither of which is an encryption technique and neither of which can be decrypted as a result.
So there is no encoding method, and no decoding method.
And if you still can't work it out, here is an Executive Summary:
You
Can't
Do
That.
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
I have seen this in this page>
it takes mobile and convert it to image and save it as file.
http://divar.ir/new/[^]
|
|
|
|
|
What has converting the image got to do with the GUID's you linked earlier?
Google translate refuses to translate the site. Can you explain me in simple terms what you're trying to achieve?
Giving a bunch of random numbers and asking for a conversion, will never work. The numbers could represent anything. Now, converting a mobile webpage, a pdf, or a document to an image, that's something we could help with.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
I have a one string in this format : abc 10 20 20 12 efg 10 20 20 13 prl 10 20 20 12 tyr 10 20 20 30 trop 10 10 20 20.
how can i split into new line as a
abc 10 20 20 12
efg 10 20 20 13
prl 10 20 20 12
tyr 10 20 20 30
trop 10 10 20 20
|
|
|
|
|
Use a regex:
[a-zA-Z]+(\s*\d+\s*)+
Should do it.
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|
|
If you need to split the alphabetic parts from the numeric parts, I'd recommend: (?'key'[a-zA-Z]+)(?'val'[0-9 ]+)
|
|
|
|
|
Hi All,
I develop a Windows form application and in the form KeyDown event
I use F8 key to do something, my problem is in any laptop contains the fn key
and F8 not work until you press the fn key, if any one click f8 only the event does not work.
Please let me know is it possible to make f8 and fn+f8 be the same functionality and how to do that in c#.
Thank You.
|
|
|
|
|
See which key is generated if you press "F8", and replace that key with it.
I'd recommend against it though. Your keyboard would suddenly work differently in your app, than compared to each and every app out there. It'd be more confusing than actually helping.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
in the BIOS you can probably swap the primary function of the fn key. i think it is called something like "action keys mode".
|
|
|
|
|
Good idea. I did that with my laptop - don't see the point in having a computer with the function keys 'disabled'.
Regards,
Rob Philpott.
|
|
|
|
|
I am looking to develop a mobile money transfer application like Vodafone. I have some doubt here,
1. In mobile money transfer how we develop the short message code like in Vodafone we dial *400# to see the menu. So, how to develop this application or this is develop by telecom company itself.
2. If i develop the application in MVC then how should i configure my application with telecom company to get real time data of users who are registered their mobile for money transfer.
3. How to integrate my mobile money application with telecom service provider and with banks.
Can you tell me the basic things that are must and the flow of it. The basic idea to develop the application.
Basically I can develop the application but main thing is that how to integrate the bank, mobile service provider, the short message service response that user send to its service provider means how to retrieve the data from service provider.
|
|
|
|
|
Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.
Only get such code from reputable banks and / or card transaction service companies - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|