根據我的轉帖的C版的例子.重寫的C#版!
首先定義一個Hash類
public class Hash : DictionaryBase { public string this[string key] { set { Dictionary[key] = value; } get { return (string)Dictionary[key]; } } public void Add(string key, string value) { Dictionary.Add(key, value); } public void Remove(string key) { Dictionary.Remove(key); } public bool Contains(string key) { return Dictionary.Contains(key); } }
具體部分
/// <summary> /// 哈希表 /// </summary> public class Test3 { private void menu() { Console.WriteLine(); Console.Write("/n* * * * * * * * * * * * * * * * * * * * * * * * * */n"); Console.Write(" 1 ------- 查找關鍵字/n"); Console.Write(" 2 ------- 插入關鍵字/n"); Console.Write(" 3 ------- 刪除關鍵字/n"); Console.Write(" 4 ------- 打印哈希表/n"); Console.Write(" 5 ------- 退出/n"); Console.Write("* * * * * * * * * * * * * * * * * * * * * * * * * */n"); Console.WriteLine(); } private bool SearchHash(Hash H, string K) { return H.Contains(K); } public bool InsertHash(Hash H, string K, string V) { if (SearchHash(H, K)) return false; else { H.Add(K, V); return SearchHash(H, K); } } private bool DeleteHash(Hash H, string K) { if (SearchHash(H, K)) { H.Remove(K); return !SearchHash(H, K); } else { return false; } } private void PrintHash(Hash H) { foreach (DictionaryEntry ent in H) { Console.WriteLine(string.Format("{0}:{1}", ent.Key, ent.Value)); } } public void menuselect(Hash H) { int k; bool done = true; while (done) { menu(); Console.Write("請選擇一個功能: "); k = Convert.ToInt32(Console.ReadLine()); switch (k) { case 1: { Console.Write("/n輸入查找數據: "); string K=Convert.ToString(Console.ReadLine()); if (SearchHash(H,K)) Console.Write("數據已找到!"); else Console.Write("數據沒找到!/n"); break; } case 2: { Console.Write("/n輸入插入數據: "); string K = Convert.ToString(Console.ReadLine()); if (InsertHash(H, K,"hello")) Console.Write("插入成功/n"); else Console.Write("此數據已經存在!/n"); break; } case 3: { Console.Write("/n輸入刪除數據: "); string K = Convert.ToString(Console.ReadLine()); if (!DeleteHash(H, K)) Console.Write("刪除數據不存在!/n"); else Console.Write("刪除成功"); break; } case 4: PrintHash(H); break; case 5: done = false; break; } } } }
1.14版(含14)視圖節點groups屬性的處理結果表現在可見性上(invisible),如果當前用戶不在指定的角色中,則設置可見性標記invisible爲"1" 2.16版(含16)以後對視圖節點groups屬性的處理
除了btree外,lightdb是支持hash index的,但是總體來說支持的特性範圍均不如btree索引,比如parallel沒有btree索引智能,不支持=之外的操作,不支持bitmap index scan,不支持哈希唯一索引(
pathlib.Path("a.crt").write_text(a[0]) p.chmod(0o444) Path.cwd() p.write_bytes(b'Binary file contents') p.read_bytes()
下載winsw程序,Releases · winsw/winsw (github.com) 將下載的exe文件放置到nginx.exe的同級目錄,名字可以修改爲nginx-service.exe(也可不修改) 新建txt文本文檔,並將其名
純CSS+單個div就能繪製抖音LOGO 關鍵點: 主要藉助了兩個僞元素實現了整體結構,藉助了 drop-shadow 生成一層整體陰影 drop-shadow 只能是單層陰影,所以另一層陰影需要多嘗試 contrast(150%) br
今天給大家介紹下一個在純 python 中構建簡歷的實用工具,工具的連接地址https://github.com/koek67/resume-builder/blob/main/readme.md 用法介紹 要求 Python 3.7 或更
前言 今天大姚給大家分享一款.NET開源(MIT License)、免費、實用的多功能原神工具箱,旨在改善桌面端玩家的遊戲體驗:胡桃工具箱。 工具箱介紹 胡桃工具箱是一款.NET開源(MIT License)、免費、實用的多功能原神工具箱
去megaton裏面的屍鬼.那裏買藥, 把破爛賣給他. 然後傳送到其他地圖, 再傳送回來, 他就又有錢和新藥了.繼續賣破爛, 買藥.刷幾次就夠了.
go裏面可以實現很多併發模型的優雅解決方案. 總結起來. package main import ( "fmt" "time" ) var bufChan chan int = make(chan int, 1000) var
本週刊由 Python貓 出品,精心篩選國內外的 250+ 信息源,爲你挑選最值得分享的文章、教程、開源項目、軟件工具、播客和視頻、熱門話題等內容。願景:幫助所有讀者精進 Python 技術,並增長職業和副業的收入。 本期週刊分享了 12
一、部署 (1)zk配置 修改zk配置文件config/zookeeper.properties,修改dataDir或端口 dataDir=/home/kafka/kafka3.7/data/zookeeper clientPort=218
什麼是鑑權(身份驗證)? https://learn.microsoft.com/zh-cn/aspnet/core/security/authentication/?view=aspnetcore-8.0 定義 鑑權,又稱身份驗證,是
使用規則引擎 其中一個配置了很多瀏覽器,另外一個配置匹配所有 ,這樣就能正常訪問。如果這兩個網站,有一個沒有使用規則引擎,那麼就會兩個網站都匹配上,然後第四條規則目標path和第一條的會拼接起來作爲oss的key,肯定不存在,所以
Problem - G - Codeforces 存個字典樹板子。 1 #include <bits/stdc++.h> 2 3 using i64 = long long; 4 5 constexpr int N
Problem - D - Codeforces 思路 補充官方正解,主要解釋一下爲什麼可以轉化爲求完全圖的歐拉路徑。題目要求構造的數的種數最少,相當於對於當前的m來說要儘可能構造出最長的序列長度,所以一定儘量要是完全圖。其次要求不