hashtable

Is it possible to sort a HashTable?

那年仲夏 提交于 2019-12-01 15:08:01
I have a property that returns a HashTable . I would like to sort it without refactoring my property. Please note : I do not want to return another type. Code: /// <summary> /// All content containers. /// </summary> public Hashtable Containers { get { Hashtable tbl = new Hashtable(); foreach (Control ctrl in Form.Controls) { if (ctrl is PlaceHolder) { tbl.Add(ctrl.ID, ctrl); } // Also check for user controls with content placeholders. else if (ctrl is UserControl) { foreach (Control ctrl2 in ctrl.Controls) { if (ctrl2 is PlaceHolder) { tbl.Add(ctrl2.ID, ctrl2); } } } } return tbl; } } Another

Is it possible to sort a HashTable?

两盒软妹~` 提交于 2019-12-01 13:59:25
问题 I have a property that returns a HashTable . I would like to sort it without refactoring my property. Please note : I do not want to return another type. Code: /// <summary> /// All content containers. /// </summary> public Hashtable Containers { get { Hashtable tbl = new Hashtable(); foreach (Control ctrl in Form.Controls) { if (ctrl is PlaceHolder) { tbl.Add(ctrl.ID, ctrl); } // Also check for user controls with content placeholders. else if (ctrl is UserControl) { foreach (Control ctrl2 in

Export a hashtable-valued property to a CSV file

人走茶凉 提交于 2019-12-01 11:29:21
I'm running the Test-AdfsServerHealth ( Ref. ) The problem is, one of the output values (value name Output ) is an array that shows up as System.Collection.Hashtable and I'm trying to find a way to get this in a neat Excel format. For instance, this is one of the actual values on the CSV when I export: Name Result Detail Output TestServiceAccountProperties Pass "" System.Collections.Hashtable But PowerShell displays: Name : TestServiceAccountProperties Result : Pass Detail : Output : {AdfsServiceAccount, AdfsServiceAccountDisabled, AdfsServiceAccountLockedOut, AdfsServiceAccountPwdExpired...}

Check whether key/value pair exists in hashtable collection

故事扮演 提交于 2019-12-01 11:12:52
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" combinathion. I need to check key/value pair combination how can I check that ? if(hash.ContainsKey("c") &&

How to write a correct Hash Table destructor in c++

穿精又带淫゛_ 提交于 2019-12-01 09:30:46
I am writing a c++ Hashtable Here is my destructor: HashMap::~HashMap() { for (int i=0; i<cap; i++) { Node* ptr = Hashtable[i]; while (ptr!=NULL) { Node* delptr; delptr=ptr; ptr=ptr->next; delete delptr; } } delete [] Hashtable; } My add function: void HashMap::add(const std::string& key, const std::string& value) { int index = hashfunction(key)%cap;; Node* ptr=Hashtable[index]; Node* newnode=new Node; if (contains(key)==false) { if (ptr == nullptr) { newnode->key=key; newnode->value=value; newnode->next=NULL; Hashtable[index]=newnode; } else { newnode->key=key; newnode->value=value; newnode-

Powershell 2 and .NET: Optimize for extremely large hash tables?

心不动则不痛 提交于 2019-12-01 09:26:37
I am dabbling in Powershell and completely new to .NET. I am running a PS script that starts with an empty hash table. The hash table will grow to at least 15,000 to 20,000 entries. Keys of the hash table will be email addresses in string form, and values will be booleans. (I simply need to track whether or not I've seen an email address.) So far, I've been growing the hash table one entry at a time. I check to make sure the key-value pair doesn't already exist (PS will error on this condition), then I add the pair. Here's the portion of my code we're talking about: ... if ($ALL_AD_CONTACTS[

Understanding Dean Edwards' addevent JavaScript

旧时模样 提交于 2019-12-01 09:21:18
I need help understanding this piece of code. What is the point of handler.guid ? Why is there a need for a hash table? What is the point of: if ( element["on" + type]) { handlers[0] = element["on" + type]; } What does the "this" refer to in handleEvent , the element or the the addEvent function? function addEvent(element, type, handler) { // assign each event handler a unique ID if (!handler.$$guid) handler.$$guid = addEvent.guid++; // create a hash table of event types for the element if (!element.events) element.events = {}; // create a hash table of event handlers for each element/event

Powershell 2 and .NET: Optimize for extremely large hash tables?

流过昼夜 提交于 2019-12-01 07:05:46
问题 I am dabbling in Powershell and completely new to .NET. I am running a PS script that starts with an empty hash table. The hash table will grow to at least 15,000 to 20,000 entries. Keys of the hash table will be email addresses in string form, and values will be booleans. (I simply need to track whether or not I've seen an email address.) So far, I've been growing the hash table one entry at a time. I check to make sure the key-value pair doesn't already exist (PS will error on this

Java - Custom Hash Map/Table Some Points

六眼飞鱼酱① 提交于 2019-12-01 06:37:01
In some previous posts I have asked some questions about coding of Custom Hash Map/Table in java. Now as I can't solve it and may be I forgot to properly mentioning what I really want, I am summarizing all of them to make it clear and precise. What I am going to do: I am trying to code for our server in which I have to find users access type by URL. Now, I have 1110 millions of URLs (approx). So, what we did, 1) Divided the database on 10 parts each of 110 millions of Urls. 2) Building a HashMap using parallel array whose key are URL's one part (represented as LONG) and values are URL's other

Join two hashtables to make one

被刻印的时光 ゝ 提交于 2019-12-01 06:04:22
I have two hash tables and I need to compare them. Let me explain my problem : [hashtable]$User = @{ "Jack" = "AdminLA, AdminUSA"; "John" = "AdminAustralia"; "Sarah" = "AdminIceland"; "Arnold" = "AdminUSA"; "Maurice" = "AdminAustralia, AdminCanada"; } [hashtable]$Profil = @{ "AdminLA" = "P1"; "AdminIceland" = "P2"; "AdminUSA" = "P3"; "AdminCanada" = "P4"; "AdminAustralia" = "P5" ; "AdminCroatia" = "P6"; } I want to have this kind of result : Key Value --- ----- Jack P1, P3 John P5 Sarah P2 Arnold P3 Maurice P5, P4 Actually, I have only one value (I haven't succeeded to have multiple values.