hashtable

Getting the current hash key in a ForEach-Object loop in powershell

≡放荡痞女 提交于 2019-12-20 17:42:19
问题 I've got a hash table: $myHash = @{ "key1" = @{ "Entry 1" = "one" "Entry 2" = "two" } "key 2" = @{ "Entry 1" = "three" "Entry 2" = "four" } } I'm doing a loop through to get the objects: $myHash.keys | ForEach-Object { Write-Host $_["Entry 1"] } Works fine, but what can I use to figure out which of the keys of $myHash I'm in? $_.Name doesn't return anything. I'm stumped. Help? 回答1: I like to use GetEnumerator() when looping a hashtable. It will give you a property value with the object, and a

What does it mean for a hash function to be incremental?

て烟熏妆下的殇ゞ 提交于 2019-12-20 12:38:35
问题 I have heard that, for example, MurmurHash2 is not "incremental" but MurmurHash3 is incremental. What does this mean? And why is it useful? 回答1: Incremental hash functions suited for situations where if a previously hashed message, M is slightly updated into a new message, M*, then it should be fairly quick to compute the hash value of the updated message, M*. This is done by computing the new hash, m*, from the old hash value, m, in contrast to conventional hash functions that have to

Why implement a Hashtable with a Binary Search Tree?

耗尽温柔 提交于 2019-12-20 12:25:05
问题 When implementing a Hashtable using an array, we inherit the constant time indexing of the array. What are the reasons for implementing a Hashtable with a Binary Search Tree since it offers search with O(logn)? Why not just use a Binary Search Tree directly? 回答1: If the elements don't have a total order (i.e. the "greater than" and "less than" is not be defined for all pairs or it is not consistent between elements), you can't compare all pairs, thus you can't use a BST directly, but nothing

What's the difference between Hashtable and Dictionary?

被刻印的时光 ゝ 提交于 2019-12-20 11:19:14
问题 What's the difference between Dictionary and Hashtable and how do I work with the Dictionary class in Java? 回答1: Dictionary is an abstract base class of Hashtable . Both are still in JDK for backwards compatibility with old code. We are expected to use HashMap and other implementations of Map interface introduced in Java 1.2. 回答2: The javadoc for Dictionary has your answer. The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values. You don't work

Trying to mix data from a CSV and a hashtable to make a variable

妖精的绣舞 提交于 2019-12-20 03:23:51
问题 I stopped over at Code Review, asking how I could streamline a script and was advised to use a hashtable as it would clean up the code. I was given a very basic example but it wasn't plug-and-play . I've worked up some basic code but it's not doing what I think it should. Knowing the Code Review folks aren't there for support like this, here i am, looking for help with combining a variable from a CSV and a hashtable. I'll leave sample data from my CSV and the Powershell code below. Sample CSV

Moving from Linear Probing to Quadratic Probing (hash collisons)

与世无争的帅哥 提交于 2019-12-20 02:43:18
问题 My current implementation of an Hash Table is using Linear Probing and now I want to move to Quadratic Probing (and later to chaining and maybe double hashing too). I've read a few articles, tutorials, wikipedia, etc... But I still don't know exactly what I should do. Linear Probing, basically, has a step of 1 and that's easy to do. When searching, inserting or removing an element from the Hash Table, I need to calculate an hash and for that I do this: index = hash_function(key) % table_size;

hash tables in powershell

拟墨画扇 提交于 2019-12-19 20:47:32
问题 I'm developing an application in PowerShell. I am storing variables in a hashtable. How can I keep the order in the hashtable? I want the order to be the same as I when I filled the hashtable. 回答1: Hash tables by nature don't maintain the order of values. There are a few workarounds already out on the net. Check these http://www.tellingmachine.com/post/2009/01/When-PowerShell-hash-table-magic-backfires.aspx http://huddledmasses.org/powershell-and-hashtable-oddities/ Or Try PS C:\WINDOWS

How do I take a compressed file (through indexes) and re-create the original file? (Java)

白昼怎懂夜的黑 提交于 2019-12-19 11:58:09
问题 Background of question I have been developing some code that focuses on firstly, reading a string and creating a file. Secondly, spliting a string into an array. Then getting the indexes for each word in the array and finally, removing the duplicates and printing it to a different file. I currently have made the code for this here is a link https://pastebin.com/gqWH0x0 (there is a menu system as well) but it is rather long so I have refrained from implementing it in this question. The

Check whether key/value pair exists in hashtable collection

情到浓时终转凉″ 提交于 2019-12-19 10:18:21
问题 I have hastable Hashtable hash = new Hashtable(); hash.Add("a", "1"); hash.Add("b","2"); hash.Add("c","3"); hash.Add("c","4" Now I need to check Key = "c" and value= "3" combination is already exits in hashtable or not. hash.ContainsKey value function cheks weather key is exists or not and ContainsValue function checks weather value is exists or not. But if I tried if( hash.Contains("c") && hash.ContainsValue("3")) { // some code heree } than it will return true for both "c,3" and "c,4"

Steps in implementing hashtable in PHP and Mysql

怎甘沉沦 提交于 2019-12-19 08:45:49
问题 I am new to programming language and I am using PHP and mysql. I got an assignment to do a hashtables in php. What I need to do is, store items that a user collected and then display it. After do some research over the internet, I will do the following steps when implement the hashtable, please correct me if I am wrong: Set up the tables: -> Users Table: uid(int[5]), username(varchar[128]), item_id(int[8], items_id_hash(int[50]) -> Items Table: item_id(int[5]), item_name(varchar[128]), items