hashtable

How to store a HashTable in the usersettings?

那年仲夏 提交于 2019-12-04 07:37:17
In .NET you can select a hashtable as type for a usersetting. However when I save it and retrieve it in this way, it doesnt seem to have saved it at all. Hashtable t = new Hashtable(); t.Add(1,"Foo"); t.Add(2,"Bar"); Properties.Settings.Default.Setting = t; Properties.Settings.Default.Save(); if(Properties.Settings.Default.Setting != null) foreach (DictionaryEntry entry in Properties.Settings.Default.Setting) { MessageBox.Show(entry.Key + " " + entry.Value); } Why doesnt it serialize it in the usersettings, when I can clearly select that type in Visual studio? I would understand if this was

Hashtable of mutable variable in Ocaml

℡╲_俬逩灬. 提交于 2019-12-04 07:22:11
I need to use hashtable of mutable variable in Ocaml, but it doesn't work out. let link = Hashtbl.create 3;; let a = ref [1;2];; let b = ref [3;4];; Hashtbl.add link a b;; # Hashtbl.mem link a;; - : bool = true # a := 5::!a;; - : unit = () # Hashtbl.mem link a;; - : bool = false Is there any way to make it works? Mutable variables that may happen to have the same content can still be distinguished because they are stored at different locations in memory. They can be compared with the physical equality operator ( == ). However, OCaml doesn't provide anything better than equality, it doesn't

Why we need the IEqualityComparer,IEqualityComparer<T> interface?

删除回忆录丶 提交于 2019-12-04 07:09:41
the 'Equal' and 'GetHashcode' method are exist in the object class, and our type inherit the object base class. what's the different between implement the two methods of the object directly and using the IComparer interface? if we overriding object's Equal and GetHashCode , and push to a hashtable , it will use the overring 's equal method? what' the differents of new a hashtable with the IEqualityComparer constructor? The IComparable interface is used when you need to be able to "sort" objects, and it gives you a method ( CompareTo ) that tells you if two objects are <, = or > . The

How to find if the value exists in hash without using key in perl?

丶灬走出姿态 提交于 2019-12-04 06:19:39
问题 I have an hash map like this my $name = 'AUS'; #dynamic values my %hash = { 'a'=>{ 'x'=> { '1' =>'US' '2' =>'UK' } 'y'=>{ '1' =>'AFRICA' '2' =>'AUS' } } 'b'=>{ 'x' =>{ '1' =>'US' '2' =>'UK' } } }; I am trying to find whether name is unique in the hash for each column foreach my $key(keys %hash) { if($name ne $hash{}{}{}) #is name unique in whole hash? { print "something"; } else { print "nothing"; } } All is fine but when it comes to key 'b' it checks that AUS is not present and prints

HashTable to Lwuit Table

℡╲_俬逩灬. 提交于 2019-12-04 06:09:46
问题 Hashtable iHashtable=new Hashtable(); iHashtable.put("Name", "Jhon"); iHashtable.put("Address","India"); Enumeration iEnumeration=iHashtable.keys(); while(iEnumeration.hasMoreElements()) { Object iresult1=iEnumeration.nextElement(); String iresult2=(String) iHashtable.get(iresult1); System.out.println(iresult1); System.out.println(iresult2); My problem is I want to put the value at LWUIT table dynamically using the HashTable key and value,here is iresult1 and iresult2,using the key and value

Lower / upper load factor in hash tables

风流意气都作罢 提交于 2019-12-04 06:03:18
问题 I am to write a chained hash set class in java. I understand the load factor is M/capacity where M is the number of elements currently in the table and capacity is the size of the table. But how does the load factor help me determine if I should resize the table and rehash or not? Also I couldn't find anywhere how to calculate the lower / upper load factors. Are they even needed? I hope this is enough information, Thank you!! 回答1: A single loadFactor used to configure standard Java hashes

Utilize Results from Synchronized Hashtable (Runspacepool 6000+ clients)

[亡魂溺海] 提交于 2019-12-04 05:48:59
问题 Adapting a script to do multiple functions, starting with test-connection to gather data, will be hitting 6000+ machines so I am using RunspacePools adapted from the below site; http://learn-powershell.net/2013/04/19/sharing-variables-and-live-objects-between-powershell-runspaces/ The data comes out as below, I would like to get it sorted into an array (I think that's the terminology), so I can sort the data via results. This will be adapted to multiple other functions pulling anything from

Python hash table for fuzzy matching

心不动则不痛 提交于 2019-12-04 04:35:18
问题 I am trying to implement a data structure which allows rapid look-ups based on keys. The python dict is great when my look-ups involve an equality (e.g. key == somevalue translates to datadict[somevalue] . The problem is that I also need to be able to efficiently look up keys based on a more complex comparison, e.g. key > 50 , or key.startswith('abc') . Obviously I can't use the same solution in both cases, but at the moment I can't figure out how to solve either case. Can anyone suggest a

Ruby maintain Hash insertion order

心已入冬 提交于 2019-12-04 03:55:16
I am looking for a way to maintain the insert order for a Hash that I am using in Ruby. My data is coming from a database and is already grouped/ordered the way I want it, but Ruby doesn't guarantee maintained order in Hashs in my version 1.8.4 . Is there any workaround for this? If not is there a way I could create a custom comparator? Here is the Hash: { "February"=>[0.5667, 14.6834, 79.7666, 261.8668, 342.1167, 723.517], "March"=>[0.0, 26.4667, 554.45, 681.3164, 2376.0668, 10353.0358], "May"=>[2.75, 34.6666, 342.1831, 1331.8999, 1589.617, 9282.9662], "July"=>[1.9, 2.3666, 59.45, 302.1501,

How to implement a dynamic-size hash table?

女生的网名这么多〃 提交于 2019-12-04 03:22:23
I know the basic principle of the hash table data structure. If I have a hash table of size N, I have to distribute my data into these N buckets as evenly as possible. But in reality, most languages have their built-in hash table types. When I use them, I don't need to know the size of hash table beforehand. I just put anything I want into it. For example, in Ruby : h = {} 10000000.times{ |i| h[i]=rand(10000) } How can it do this? svick See the Dynamic resizing section of the Hash table article on Wikipedia . The usual approach is to use the same logic as a dynamic array : have some number of