导航:首页 > 数据分析 > 哈希数据存储在哪里

哈希数据存储在哪里

发布时间:2023-06-08 22:52:27

『壹』 hash查找算法 数据量在10万左右 数据库中存储

可以用,但是最好加入缓存机制。

『贰』 java中hashtable怎样存储数据和读取数据

Hashtable-哈希表类

以哈希表的形式存储数据,数据的形式是键值对.
特点:
查找速度快,遍历相对慢
键值不能有空指针和重复数据

创建
Hashtable<Integer,String> ht=new
Hashtable<Integer,String>();

添值

ht.put(1,"Andy");
ht.put(2,"Bill");
ht.put(3,"Cindy");
ht.put(4,"Dell");
ht.put(5,"Felex");
ht.put(6,"Edinburg");
ht.put(7,"Green");

取值

String str=ht.get(1);
System.out.println(str);// Andy

对键进行遍历

Iterator it = ht.keySet().iterator();

while (it.hasNext()) {
Integer key = (Integer)it.next();

System.out.println(key);
}

对值进行遍历

Iterator it = ht.values().iterator();

while (it.hasNext()) {
String value =(String) it.next();

System.out.println(value);
}

取Hashtable记录数

Hashtable<Integer,String> ht=new Hashtable<Integer,String>();

ht.put(1,"Andy");
ht.put(2,"Bill");
ht.put(3,"Cindy");
ht.put(4,"Dell");
ht.put(5,"Felex");
ht.put(6,"Edinburg");
ht.put(7,"Green");

int i=ht.size();// 7

删除元素

Hashtable<Integer,String> ht=new Hashtable<Integer,String>();

ht.put(1,"Andy");
ht.put(2,"Bill");
ht.put(3,"Cindy");
ht.put(4,"Dell");
ht.put(5,"Felex");
ht.put(6,"Edinburg");
ht.put(7,"Green");

ht.remove(1);
ht.remove(2);
ht.remove(3);
ht.remove(4);

System.out.println(ht.size());// 3

Iterator it = ht.values().iterator();

while (it.hasNext()) {
// Get value
String value =(String)
it.next();
System.out.println(value);
}

阅读全文

与哈希数据存储在哪里相关的资料

热点内容
鼠标右键的压缩文件 浏览:44
awr导出cad文件 浏览:925
参公文件去哪里找 浏览:827
excel表批量日期设置成文件夹存放 浏览:90
如何把数据库加入其中 浏览:661
编程除法怎么取消取整 浏览:625
股票编程软件哪里有卖 浏览:503
access导入多个txt文件 浏览:917
大脸app安卓下载 浏览:439
怎么休改文件名 浏览:989
cdr导出图片不显示文件名 浏览:761
pcdmis如何离线编程 浏览:201
微信推文插入文件 浏览:844
生产文件柜图片 浏览:244
如何设置微信数据增加 浏览:95
excel文件不再增大 浏览:613
ug编程刀路怎么复制不用鼠标选取 浏览:97
excel文件打开扩展名错误 浏览:10
阿里巴巴怎么做数据包 浏览:442
无线网络连接一直显示未连接 浏览:25

友情链接