package com.wangzhu.map;import java.util.HashMap;/** * hashCode方法的主要作用是为了配合基于散列的集合一起正常运行, * 这样的散列集合包括HashSet、HashMap以及HashTable。 * 能否可以直接根据hashCode值判断...
分类:
其他好文 时间:
2015-02-02 00:41:07
阅读次数:
205
1 数据是外部世界的载体,能够被计算机处理加工。2数据元素是数据的基本单位,如,学生的姓名、性别、班级等等。3数据对象是数据的一个集合,如 人类,狗类,等等属于数据对象,对象里又有数据元素4数据类型,如整形,字符串,结构体等等,5.数据结构通常分为4种,5.1集合 如HashSet类主要是设计用来做...
//新建一个HashSetHashSet sixHashSet = new HashSet();//满6位时结束循环 while (sixHashSet.size() != 6) { String temp = Integer.toString((int) (Math.random() * ...
分类:
编程语言 时间:
2015-01-31 00:17:24
阅读次数:
153
ArrayList没有封装好的去重方法,比如对于一个[2, 5, 2, 3, 2, 4]的ArrayList,我要去除其中的重复的元素,
我也不想把语句也这么长,也不想用for循环的方法去重,那么可以先考虑把ArrayList转化为一个临时的HashSet,再把这个临时的HashSet转化回ArrayList,
因为HashSet里面的元素是不可重复的嘛!至于什么是ArrayList与Hash...
分类:
编程语言 时间:
2015-01-29 10:32:42
阅读次数:
108
本文借鉴优秀文章:http://blog.csdn.net/zhangerqing/article/details/8122075
数据结构:
下面的表格也许可以更直接的表现出他们之间的区别和联系:
接口
简述
实现
操作特性
成员要求
Set
...
分类:
编程语言 时间:
2015-01-29 09:37:03
阅读次数:
176
一.HashSet源代码HashSet的实现对于HashSet而言,它是基于HashMap实现的,HashSet底层采用HashMap来保存所有元素,因此HashSet的实现比较简单,查看HashSet的源代码,可以看到如下代码:Java代码publicclassHashSetextendsAbst...
分类:
编程语言 时间:
2015-01-28 14:34:18
阅读次数:
227
static final int DEFAULT_INITIAL_CAPACITY = 1 [] EMPTY_TABLE = {}; //就比较用的 transient Entry[] table = (Entry[]) EMPTY_TABLE;//Entry数组,存放数据的地方 int...
分类:
其他好文 时间:
2015-01-27 23:11:25
阅读次数:
247
HashSet,ArrayList,集合,内存泄露
分类:
其他好文 时间:
2015-01-27 21:36:38
阅读次数:
186
描述:
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the targ...
分类:
其他好文 时间:
2015-01-27 20:24:52
阅读次数:
213
描述:
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without
repeating letters for "abcabcbb" is "abc", which the length is ...
分类:
其他好文 时间:
2015-01-27 20:21:40
阅读次数:
149