javascript实现的HashMap类代码
(编辑:jimmy 日期: 2025/5/12 浏览:3 次 )
复制代码 代码如下:
<script language = "javascript" >
function HashMap() {
/**Map大小**/
var size = 0;
/**对象**/
var entry = new Object();
/**Map的存put方法**/
this.put = function(key, value) {
if (!this.containsKey(key)) {
size++;
entry[key] = value;
}
}
/**Map取get方法**/
this.get = function(key) {
return this.containsKey(key) "A", "1");
hashMap.put("B", "2");
hashMap.put("A", "5");
hashMap.put("C", "3");
hashMap.put("A", "4");
alert(hashMap.size());
</script>
下一篇:js图片滚动效果时间可随意设定当鼠标移上去时停止