hashtable

Fast disk-based hashtables?

耗尽温柔 提交于 2019-11-26 19:06:16
问题 I have sets of hashes (first 64 bits of MD5, so they're distributed very randomly) and I want to be able to see if a new hash is in a set, and to add it to a set. Sets aren't too big, the largest will be millions of elements, but there are hundreds of sets, so I cannot hold them all in memory. Some ideas I had so far: I tried just keeping it all in sqlite table, but it becomes really really slow once it cannot fit everything in memory. Bloom filters sound like they would have very high error

Hash Table/Associative Array in VBA

不羁岁月 提交于 2019-11-26 18:51:15
I can't seem to find the documentation explaining how to create a hash table or associative array in VBA. Is it even possible? Can you link to an article or better yet post the code? I think you are looking for the Dictionary object, found in the Microsoft Scripting Runtime library. (Add a reference to your project from the Tools...References menu in the VBE.) It pretty much works with any simple value that can fit in a variant (Keys can't be arrays, and trying to make them objects doesn't make much sense. See comment from @Nile below.): Dim d As dictionary Set d = New dictionary d("x") = 42 d

What's the logic behind Python's hash function order?

佐手、 提交于 2019-11-26 18:37:33
问题 As we know, Some of Python's data structures use hash tables for storing items like set or dictionary . So there is no order in these objects. But it seems that, for some sequences of numbers that's not true. For example consider the following examples : >>> set([7,2,5,3,6]) set([2, 3, 5, 6, 7]) >>> set([4,5,3,0,1,2]) set([0, 1, 2, 3, 4, 5]) But it isn't sorted if we make a small change : >>> set([8,2,5,3,6]) set([8, 2, 3, 5, 6]) So the question is: How does Python's hash function work on

The fastest way to retrieve 16k Key-Value pairs?

霸气de小男生 提交于 2019-11-26 18:36:47
问题 OK, here's my situation : I have a function - let's say U64 calc (U64 x) - which takes a 64-bit integer parameter, performs some CPU-intensive operation, and returns a 64-bit value Now, given that I know ALL possible inputs (the x s) of that function beforehand (there are some 16000 though), I thought it might be better to pre-calculate them and then fetch them on demand (from an array-like structure). The ideal situation would be to store them all in some array U64 CALC[] and retrieve them

Tuples( or arrays ) as Dictionary keys in C#

橙三吉。 提交于 2019-11-26 17:27:14
I am trying to make a Dictionary lookup table in C#. I need to resolve a 3-tuple of values to one string. I tried using arrays as keys, but that did not work, and I don't know what else to do. At this point I am considering making a Dictionary of Dictionaries of Dictionaries, but that would probably not be very pretty to look at, though it is how I would do it in javascript. If you are on .NET 4.0 use a Tuple: lookup = new Dictionary<Tuple<TypeA, TypeB, TypeC>, string>(); If not you can define a Tuple and use that as the key. The Tuple needs to override GetHashCode, Equals and IEquatable:

Time complexity of Hash table

风流意气都作罢 提交于 2019-11-26 17:24:35
I am confused about the time complexity of hash table many articles state that they are "amortized O(1)" not true order O(1) what does this mean in real applications. What is the average time complexity of the operations in a hash table, in actual implementation not in theory, and why are the operations not true O(1)? It's impossible to know in advance how many collisions you will get with your hash function, as well as things like needing to resize. This can add an element of unpredictability to the performance of a hash table, making it not true O(1). However, virtually all hash table

Why are entries in addition order in a .Net Dictionary?

痴心易碎 提交于 2019-11-26 17:22:34
问题 I just saw this behaviour and I'm a bit surprised by it... If I add 3 or 4 elements to a Dictionary, and then do a "For Each" to get all the keys, they appear in the same order I added them. The reason this surprises me is that a Dictionary is supposed to be a HashTable internally, so I expected things to come out in ANY order (ordered by the hash of the key, right?) What am I missing here? Is this a behaviour I can count on? EDIT: OK, I thought already of many of the reasons why this might

What hashing function does Java use to implement Hashtable class?

房东的猫 提交于 2019-11-26 17:03:00
From the book CLRS ("Introduction to Algorithms"), there are several hashing functions, such as mod, multiply, etc. What hashing function does Java use to map the keys to slots? I have seen there is a question here Hashing function used in Java Language . But it doesn't answer the question, and I think the marked answer for that question is wrong. It says that hashCode() let you do your own hashing function for Hashtable, but I think it is wrong. The integer returned by hashCode() is the real key for Hashtble, then Hashtable uses a hashing function to hash the hashCode(). What this answer

Associative arrays in Shell scripts

时间秒杀一切 提交于 2019-11-26 16:56:22
We required a script that simulates Associative arrays or Map like data structure for Shell Scripting, any body? Jerry Penner To add to Irfan's answer , here is a shorter and faster version of get() since it requires no iteration over the map contents: get() { mapName=$1; key=$2 map=${!mapName} value="$(echo $map |sed -e "s/.*--${key}=\([^ ]*\).*/\1/" -e 's/:SP:/ /g' )" } Another option, if portability is not your main concern, is to use associative arrays that are built in to the shell. This should work in bash 4.0 (available now on most major distros, though not on OS X unless you install it

Hashtable to Dictionary<> syncroot .

折月煮酒 提交于 2019-11-26 16:54:05
问题 Hashtables have a syncroot property but generic dictionaries don't. If I have code that does this: lock (hashtable.Syncroot) { .... } How do I replicate this if I am removing the hashtable and changing to generic dictionaries? 回答1: If you are going strictly for compatability then Bryan is correct. This is the best way to maintain your current semantics on top of a Dictionary. Expanding on it though. The reason the SyncRoot property was not directly added to the generic dictionary is that it's