unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} uses
IniFiles; //TStringHash 来自 IniFiles 单元
var
Hash: TStringHash; { TStringHash 的功能非常简单, 如果需要更多功能应该使用: THashedStringList
TStringHash 与 THashedStringList、TStringList 最大的不同是:
TStringHash 的 Key 必须是 String; Value 必须是 Integer.
如果这不适合你的要求, 建一个 TMyHash 也不是难事 } //建立哈希表
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Hash := TStringHash.Create(); // 是表的初始大小, 可以省略使用默认值256
for i := to do
begin
Hash.Add(Chr(i),i); //如果表不够大,会自动增加的
end;
end; //读取
procedure TForm1.Button1Click(Sender: TObject);
var
num: Integer;
begin
num := Hash.ValueOf('Z');
ShowMessage(IntToStr(num)); //
end; //修改、删除、清空
procedure TForm1.Button2Click(Sender: TObject);
begin
Hash.Modify('Z',); //修改
Hash.Remove('A'); //删除
Hash.Clear; //清空 {没了, 就这些功能}
end; procedure TForm1.FormDestroy(Sender: TObject);
begin
Hash.Free;
end; end.

Delphi 中的哈希表(二)—— TStringHash的更多相关文章

  1. Delphi 中的哈希表: THashedStringList

    转自万一博客 Delphi 中的哈希表: THashedStringList unit Unit1; interface uses   Windows, Messages, SysUtils, Var ...

  2. [转]:Delphi 中的哈希表(1): THashedStringList

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  3. [PHP内核探索]PHP中的哈希表

    在PHP内核中,其中一个很重要的数据结构就是HashTable.我们常用的数组,在内核中就是用HashTable来实现.那么,PHP的HashTable是怎么实现的呢?最近在看HashTable的数据 ...

  4. Python 中的哈希表

    Python 中的哈希表:对字典的理解   有没有想过,Python中的字典为什么这么高效稳定.原因是他是建立在hash表上.了解Python中的hash表有助于更好的理解Python,因为Pytho ...

  5. 【PAT甲级】1078 Hashing (25 分)(哈希表二次探测法)

    题意: 输入两个正整数M和N(M<=10000,N<=M)表示哈希表的最大长度和插入的元素个数.如果M不是一个素数,把它变成大于M的最小素数,接着输入N个元素,输出它们在哈希表中的位置(从 ...

  6. OVS 中的哈希表: shash

    shash出现在OVS的代码中,定义如下:   struct hmap_node {     size_t hash;     struct hmap_node * next; };   struct ...

  7. Freemarker 中的哈希表(Map)和序列(List)

    freemarlker中的容器类型有: 哈希表:是实现了TemplateHashModel或者TemplateHashModelEx接口的java对象,经常使用的实现类是SimpleHash,该类实现 ...

  8. delphi中使用webbrowser提交表单

    转自:http://blog.163.com/hehaifeng1984@126/blog/static/6900113620133504644998/ 我们以百度搜索为例,使用webbrowser组 ...

  9. PAT-1145(Hashing - Average Search Time)哈希表+二次探测解决冲突

    Hashing - Average Search Time PAT-1145 需要注意本题的table的容量设置 二次探测,只考虑正增量 这里计算平均查找长度的方法和书本中的不同 #include&l ...

随机推荐

  1. 使用ASP.NET 5开发AngularJS应用

    今天推荐的是一个系列文章,讲述了如何使用ASP.NET 5来开发AngularJS应用,一共7篇文章. 在Visual Studio 2015中由于优化了项目结构,优化了前端JS框架的引用方式,所以开 ...

  2. 电赛菜鸟营培训(四)——STM32F103CB之ADC转换

    一.ADC概念 实现模拟信号转换成数字信号就是这样子= = 二.代码框架 #include "stm32f10x.h" void delay(u32 kk) { while(kk- ...

  3. 关于Strut2内置Json插件的使用

    配置注意点: 在原有Struts2框架jar包的引入下,需要额外多加一个Json的插件包(struts2-json-plugin-2.3.7.jar) 在struts.xml配置文件中,包需要继承js ...

  4. mysql一次插入多条数据

    mysql一次插入多条数据: INSERT INTO hk_test(username, passwd) VALUES ('qmf2', 'qmf2'),('qmf3', 'qmf3'),('qmf4 ...

  5. 绑定GoDaddy域名到OpenShift应用

    一.申请GoDaddy域名 二.托管OpenShift应用 三.绑定www.mydomain.com 四.重定向mydomin.com到www.mydomain.com 五.It's go time ...

  6. POJ1797 Heavy Transportation(SPFA)

    题目要求1到n点的最大容量的增广路. 听说是最短路求的,然后乱搞就A了.. 大概能从Bellman-Ford的思想,dk[u]表示从源点出发经过最多k条边到达u点的最短路,上理解正确性. #inclu ...

  7. [leetCode][012] Two Sum (1)

    [题目]: Given an array of integers, find two numbers such that they add up to a specific target number ...

  8. 【BZOJ】1818: [Cqoi2010]内部白点(树状数组+离散+特殊的技巧)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1818 这一题一开始我就看错了,bzoj的那个绝对值109简直坑人,应该是10^9,我直接写了个暴力. ...

  9. POJ 3286 How many 0's?(数位DP)

    题目链接 终于过了,边界让我wa了好几次,猥琐的用AC代码对拍,很无奈,用非常麻烦的方法.写一下,估计以后再碰到,肯定看不懂这是写的什么了. 以前做过,统计1和2的,统计0比1和2麻烦多了,有前导0的 ...

  10. MySQL 里面的Where 和Having和Count 和distinct和Group By对比

    mysql> select accid as uid,date(datetime) AS datetime from game.logLogin GROUP BY accid HAVING da ...