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. zxing实现二维码生成和解析

    转自:http://kesun-shy.iteye.com/blog/2154169 二维码的生成与解析.有多种途径.我选择用大品牌,google老大的zxing. gitHub链接是(我用的3.0. ...

  2. 浅谈c++ new and delete or new [] and delete []

    http://www.cnblogs.com/hazir/p/new_and_delete.html 在 C++ 中,你也许经常使用 new 和 delete 来动态申请和释放内存,但你可曾想过以下问 ...

  3. 使用sqljdbc连接mssql数据库,maven生成jar运行后报"Exception in thread "main" java.lang.SecurityException"错误

    错误信息如下: Exception in thread "main" java.lang.SecurityException: Invalid signature file dig ...

  4. 使用redis-cli定时执行指定命令

    50 20 * * * echo "del counterv2_real" | redis-cli -h hosts -a id:pwd --pipe

  5. 登录Cloudera Manager时报错org.hibernate.exception.GenericJDBCException: Could not open connection

    去Cloudera Server上边看了一下日志: cat /opt/cloudera-manager/log/cloudera-scm-server/cloudera-scm-server.log ...

  6. 5.post上传和压缩、插件模拟请求

      gzip gzip一种压缩方式,或者是文件形式,它主要用于网络传输数据的压缩 gzip压缩好不好用 浏览器:网速一定.内容越小.请求响应的速度是不是更快 手机server:返回数据类型是json/ ...

  7. ThreadLocal使用和原理

    实现机制 1.每个Thread对象内部都维护了一个ThreadLocalMap这样一个ThreadLocal的Map,可以存放若干个ThreadLocal. /* ThreadLocal values ...

  8. QUnit使用笔记-3测试用户操作

    模拟操作: elem.trigger(event); elem.triggerHandler(event); triggerHandler的不同: 不会引起事件的默认行为 .trigger() 会操作 ...

  9. HealthKit开发快速入门教程之HealthKit开发概述简介

    HealthKit开发快速入门教程之HealthKit开发概述简介 2014年6月2日召开的年度开发者大会上,苹果发布了一款新的移动应用平台,可以收集和分析用户的健康数据.该移动应用平台被命名为“He ...

  10. Sprint第一个冲刺(第十一天)

    一.Sprint介绍 修改登录信息界面(修改用户名.密码.邮箱.电话.年龄),且同步到云端:修改Item布局:增添设置页. 实验截图: 任务进度: 二.Sprint周期 看板: 燃尽图: