hashtable

Find a value from a hashtable

最后都变了- 提交于 2021-02-07 18:19:16
问题 If I were having a Generic list I would have done some thing like this myListOfObject.FindAll(x=>(x.IsRequired==false)); What if I need to do similar stuff in Hashtable ? Copying to temporary hashtable and looping and comparing would be that last thing I would try :-( 回答1: Firstly, use System.Collections.Generic.Dictionary<TKey, TValue> for better strong-type support as opposed to Hashtable . If you need to just find one key or one value, use the methods ContainsKey(object key) or

Is SELECT WHERE [primary key] = [primary key value] O(1)?

做~自己de王妃 提交于 2021-02-07 08:26:02
问题 Is it right to expect that, for the typical modern RDBMS, querying by one specific primary key is as fast as querying a hashtable by key? Or is there "actual work" done to traverse the table and track down the primary key value? That seems unthinkably wasteful, even if there are automatic indexes for primary keys. 回答1: Database operation involves access of secondary memory unit (Disk). And to achieve efficiency important is to reduce block access time(not operations). Complexity of Select

Is SELECT WHERE [primary key] = [primary key value] O(1)?

本秂侑毒 提交于 2021-02-07 08:24:04
问题 Is it right to expect that, for the typical modern RDBMS, querying by one specific primary key is as fast as querying a hashtable by key? Or is there "actual work" done to traverse the table and track down the primary key value? That seems unthinkably wasteful, even if there are automatic indexes for primary keys. 回答1: Database operation involves access of secondary memory unit (Disk). And to achieve efficiency important is to reduce block access time(not operations). Complexity of Select

Is Hashtable.Synchronized suitable for use as a simple cache in a multithreaded environment?

99封情书 提交于 2021-02-05 08:48:06
问题 I'm currently using a Hashtable wrapped as a Hashtable.Synchronized as a simple cache in a library that could be used by a multi-threaded environment (such as asp.net) - is this a suitable use for this collection? I understand that there are more suitable constructs available in .Net 4.0, but I'm stuck with .Net 3.5. If it makes any difference, this cache is read from frequently, and is written to very infrequently (but needs to remain threadsafe). Basic usage is something along the lines of:

Show content of hashtable when Pester test case fails

让人想犯罪 __ 提交于 2021-02-05 07:55:23
问题 Problem When a Hashtable is used as input for Should , Pester outputs only the typename instead of the content: Describe 'test' { It 'test case' { $ht = @{ foo = 21; bar = 42 } $ht | Should -BeNullOrEmpty } } Output: Expected $null or empty, but got @(System.Collections.Hashtable). Expected output like: Expected $null or empty, but got @{ foo = 21; bar = 42 }. Cause Looking at Pester source, the test input is formatted by private function Format-Nicely , which just casts to String if the

Hash function issue - adding functionality

自闭症网瘾萝莉.ら 提交于 2021-01-28 19:30:48
问题 I tried adding functionality to the djb2 hash function, but it doesn't appear to like the changes. Specifically, I'm trying to include a loop that converts words (strings) to lower case. It throws the following two errors: Incompatible integer to pointer conversion assigning to char * from int Cannot increment value of type char *[45] Note that in the original code *str++ appeared in the while loop. This is my first hash table, and I'm rather shaky on pointers. Any insight on where I've gone

Hash function issue - adding functionality

落花浮王杯 提交于 2021-01-28 19:21:47
问题 I tried adding functionality to the djb2 hash function, but it doesn't appear to like the changes. Specifically, I'm trying to include a loop that converts words (strings) to lower case. It throws the following two errors: Incompatible integer to pointer conversion assigning to char * from int Cannot increment value of type char *[45] Note that in the original code *str++ appeared in the while loop. This is my first hash table, and I'm rather shaky on pointers. Any insight on where I've gone

Get hashtable obj by key & change its public properties

允我心安 提交于 2021-01-28 18:54:30
问题 First of all I declare a hashtable and its values. The key of a hashtable entry is a GUID and the value is an object with a few string values. Guid g = Guid.NewGuid(); Hashtable hash = new Hashtable(); InstallationFiles instFiles = new InstallationFiles(string1, string2, string3); hash.Add(g, instFiles); //...add many other values with different GUIDs... My goal is to give a user a possibility to EDIT string 1, string2, string3. To cut a long story short, I am in a position where I can get

Hashtables/Dictionaries that use floats/doubles

故事扮演 提交于 2021-01-27 21:00:51
问题 I read somewhere about other data structures similar to hashtables, dictionaries but instead of using ints, they were using floats/doubles, etc. Anyone knows what they are? 回答1: If you mean using floats/doubles as keys in your hash, that's easy. For example, in .NET, it's just using Dictionary<double,MyValueType> . If you're talking about having the hash be based off a double instead of an int.... Technically, you can have any element as your internal hash. Normally, this is done using an int

How do you add up certain values in hashtable based off of user input?

早过忘川 提交于 2021-01-27 19:01:37
问题 I am trying to make a gematria calculator in Java and to try to get the same results I am getting with python. How would I get so in java it could print the sum of the values from what the user inputs and get the same ultimate result as I would in python? Please note I'm a beginner at java so forgive me for any ignorance in this question. I managed to make one in python and want to do something conceptually similar in java. In python, I had a dictionary with all the English letters and their