HashMap和HashTable之间的差异纯粹在数据结构中 [英] Difference between HashMap and HashTable purely in Data Structures

查看:122
本文介绍了HashMap和HashTable之间的差异纯粹在数据结构中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c $ c> HashTable 和 HashMap 在数据结构的上下文中有什么区别(而不是在Java或任何其他语言)



我已经看到有人为同一个概念交换了这些术语。纯粹在数据结构 的背景下,它们之间没有区别

解决方案

在计算科学术语中,地图是从键到值的关联容器映射。换句话说,您可以执行K键记忆值V等操作,稍后再按K键取值。地图可以以许多方式实现 - 例如,使用(可选的平衡)二进制树或哈希表,或者甚至连接存储键/值的结构数组。


$ b $哈希表
是用于存储任意数据的结构,并且数据不一定由单独的键和值组成。例如,我可以有一个包含值为{1,10,33,97}的哈希表,这将是他们自己的密钥。当没有与密钥不同的值时,这有时被称为集合,并且哈希表实现是哈希集。



所以,a哈希表存储元素,每个元素不需要由不同的键和值组件组成,但是如果它是哈希图。


What is the difference between HashTable and HashMap purely in context of Data Structures(and not in Java or any other language).

I have seen people using these terms interchangeably for the same concept. Does it have no difference at all purely in context of Data Structures!

解决方案

In Computing Science terminology, a map is an associative container mapping from a key to a value. In other words, you can do operations like "for key K remember value V" and later "for key K get the value". A map can be implemented in many ways - for example, with a (optionally balanced) binary tree, or a hash table, or even a contiguous array of structs storing the key/value.

A hash table is a structure for storing arbitrary data, and that data does not necessarily consist of a separate key and value. For example, I could have a hash table containing the values { 1, 10, 33, 97 }, which would be their own keys. When there is no value distinct from the key, this is sometimes known as a "set", and with a hash table implementation a "hash set".

So, a hash table stores elements, each of which need not consist of distinct key and value components, but if it does then it's also a hash map.

这篇关于HashMap和HashTable之间的差异纯粹在数据结构中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆