Delphi中类似Map的HashTable
来源:互联网 发布:大数据平台和云平台 编辑:程序博客网 时间:2024/05/22 04:39
From: http://topic.csdn.net/t/20050518/10/4015559.html
unit UnitHasedTable; interface uses Classes; type TStringHashedTable = class(TPersistent) FKeyList: TStrings; FStrList: TStrings; private function GetItems(Key: string): string; procedure SetItems(Key: string; const Value: string); function GetCount: Integer; public constructor Create; destructor Destroy; override; property Items[Key: string]: string read GetItems write SetItems; default; property Count: Integer read GetCount; procedure Add(Key, Str: string); procedure Delete(Key:String); end; implementation { TStringHashedTable } procedure TStringHashedTable.Add(Key, Str: string); begin if FKeyList.IndexOf(Key) <> -1 then begin Exit; end; FKeyList.Add(Key); FStrList.Add(Str); end; constructor TStringHashedTable.Create; begin FKeyList := TStringList.Create; FStrList := TStringList.Create; end; procedure TStringHashedTable.Delete(Key:String); var KeyIndex:Integer; begin KeyIndex := FKeyList.IndexOf(Key); FKeyList.Delete(KeyIndex); FStrList.Delete(KeyIndex); end; destructor TStringHashedTable.Destroy; begin FStrList.Free; FKeyList.Free; inherited Destroy; end; function TStringHashedTable.GetCount: Integer; begin Result := FKeyList.Count; end; function TStringHashedTable.GetItems(Key: string): string; var KeyIndex : Integer; begin KeyIndex :=FKeyList.IndexOf(Key); Result := FStrList[KeyIndex]; end; procedure TStringHashedTable.SetItems(Key: string; const Value: string); var KeyIndex : Integer; begin KeyIndex :=FKeyList.IndexOf(Key); FStrList[KeyIndex] := Value; end; end.
- Delphi中类似Map的HashTable
- Map中HashMap和HashTable的区别
- c语言实现hashtable,类似C++的map和iOS的NSDictionary
- C#中有类似Delphi中Action的功能吗?
- Java中对Map(HashMap,TreeMap,Hashtable等)的排序
- Java中对Map(HashMap,TreeMap,Hashtable等)的排序
- Java中Map与HashMap,Hashtable,HashSet的区别
- Java中Map与HashMap,Hashtable,HashSet的区别
- 【java】Java中Map与HashMap,Hashtable,HashSet的区别
- Java中Map与HashMap,Hashtable,HashSet的区别
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- Java中Map与HashMap,Hashtable,HashSet的区别
- java 中Map 常用的子类 之 Hashtable
- Delphi自己定义的string类型的Map,类似java的HashMap
- Delphi中实现C++/Java类似静态变量的功能
- Delphi中实现C++/Java类似静态变量的功能
- tomcat启动时出现的 严重: Error listenerStart (转载)
- IE6 Bugs(二)
- 软件开发模型
- 在百度中更多的资料
- js判断数字,字母,中文
- Delphi中类似Map的HashTable
- QTP9.5的补丁
- python中遇到的小问题
- SMART原则-以及设立确定的工作
- 今天四六级考后感想
- tp
- 今天四六级考后感想
- 今天四六级考后感想
- 今天四六级考后感想