hashtable

How does one retrieve the hash code of an enumeration without boxing it?

走远了吗. 提交于 2019-12-04 02:40:43
If one has an enumeration stored inside an aggregate type, one might want to include that inside the type's hash code (assuming a typical " multiply by primes " hash function). If one just calls SomeEnum.GetHashCode() , it appears that the JIT boxes the instance, even in release builds. Profiling this shows some 10% of the time of my application spent boxing enumerations inside various GetHashCode functions. Several value types implement IEquatable or similar interfaces, which allows calling GetHashCode as a static method; which avoids the boxing. But System.Enum doesn't provide the static

Salting: Is it reasonable to use the user name?

烈酒焚心 提交于 2019-12-04 02:02:15
I am debating using user-names as a means to salt passwords, instead of storing a random string along with the names. My justification is that the purpose of the salt is to prevent rainbow tables, so what makes this realistically less secure than another set of data in there? For example, hash( md5(johnny_381@example.com), p4ss\/\/0rD) vs hash( md5(some_UUID_value), p4ss\/\/0rD) Is there a real reason I couldn't just stick with the user name and simplify things? The only thing my web searching resulted was debates as to how a salt should be like a password, but ended without any reasoning

Merging hashtables in PowerShell: how?

一个人想着一个人 提交于 2019-12-03 23:58:17
问题 I am trying to merge two hashtables, overwriting key-value pairs in the first if the same key exists in the second. To do this I wrote this function which first removes all key-value pairs in the first hastable if the same key exists in the second hashtable. When I type this into PowerShell line by line it works. But when I run the entire function, PowerShell asks me to provide (what it considers) missing parameters to foreach-object. function mergehashtables($htold, $htnew) { $htold

Cuckoo hashing in C

折月煮酒 提交于 2019-12-03 23:14:50
Does anybody have an implementation of Cuckoo hashing in C? If there was an Open Source, non GPL version it would be perfect! Since Adam mentioned it in his comment, anyone knows why it is not much used? Is it just a matter of implementation or the good theoretical properties do not materialize in practice? http://www.mpi-inf.mpg.de/~sanders/programs/cuckoo/ HTH As other answers have pointed out, it's true that the simplest cuckoo hashtable requires that the table be half empty. However, the concept has been generalized to d -ary cuckoo hashing, in which each key has d possible places to nest,

Does the STL contain a hashtable? [duplicate]

感情迁移 提交于 2019-12-03 22:36:53
Possible Duplicates: Hashtable in C++? can anybody offer a simple hash_map example in C++? Does the STL contain an implementation of a hashtable? If so, can you provide a brief example of how to use it? Current standard implementation doesn't, STL::TR1 does, see Unordered Map . Most modern compilers have a TR1 implementation, if that fails, you may always use the Boost TR1 implementation. MSVC has it for VS2008 via service pack 1 GCC has it shipped with 4.x, but you can make it work with 3.4.x too AFAIR Usage is almost the same as with a std::map. While not officially part of the STL standard,

Property passed to Invoke-Command changes type from IDictionary to HashTable

跟風遠走 提交于 2019-12-03 20:45:52
I've been getting an error running Invoke-Command where the script block takes a parameter of type dictionary: Cannot process argument transformation on parameter 'dictionary'. Cannot convert the "System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type "System.Collections.Generic.IDictionary`2[System.String,System.String]". At line:7 char:1 + Invoke-Command -ComputerName . -ArgumentList $dictionary -ScriptBlock ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [], ParameterBindin...mationException +

ANSI C hash table implementation with data in one memory block

懵懂的女人 提交于 2019-12-03 20:18:45
I am looking for an open source C implementation of a hash table that keeps all the data in one memory block, so it can be easily send over a network let say. I can only find ones that allocate small pieces of memory for every key-value pair added to it. Thank you very much in advance for all the inputs. EDIT: It doesn't necessarily need to be a hash table, whatever key-value pair table would probably do. On a unix system I'd probably utilise a shared memory buffer (see shm_open() ), or if that's not available a memory-mapped file with the MAP_SHARED flag, see the OS-specific differences

Ternary Tree Vs Hash Table

荒凉一梦 提交于 2019-12-03 19:05:31
问题 I need to know if a ternary tree is better than a hash table. I came across this question in a reply to another question I had where someone said that ternary trees are often faster than hash tables. I found that hard to believe, so I decided to research a little into it. This one website from Princeton appears to be the source of the belief. I took a look at algorithm which is described to be O(log n + k) where n is the number of words stored, and k is the length of the key. It seems to me

Hash table - implementing with Binary Search Tree

五迷三道 提交于 2019-12-03 17:09:32
From Cracking the Coding Interview , page 71: Alternatively, we can implement hash table with a BST. We can then guarantee an O(log n) lookup time, since we can keep the tree balanced. Additionally we may use less space, since a large array no longer needs to be allocated in the very beginning. I know the basics of linked lists, hash tables and BSTs, but I am unable to understand these lines. What does it actually mean? Would this final data structure would be a Trie? The full text of that section states, with the last paragraph being the one you asked about: A hash table is a data structure

Pointer to generic type

泪湿孤枕 提交于 2019-12-03 16:12:35
In the process of transforming a given efficient pointer-based hash map implementation into a generic hash map implementation, I stumbled across the following problem: I have a class representing a hash node (the hash map implementation uses a binary tree) THashNode <KEY_TYPE, VALUE_TYPE> = class public Key : KEY_TYPE; Value : VALUE_TYPE; Left : THashNode <KEY_TYPE, VALUE_TYPE>; Right : THashNode <KEY_TYPE, VALUE_TYPE>; end; In addition to that there is a function that should return a pointer to a hash node. I wanted to write PHashNode = ^THashNode <KEY_TYPE, VALUE_TYPE> but that doesn't