java.util.HashSet
2024-10-19 07:36:47
Operations | Time Complexity | Notes |
add, remove, contains, size | O(1) | assuming the hash functions has dispersed the elements properly among the buckets |
iteration | proportional to the number of the elememts and buckets | do not set the initial capacity too high(or the load factor too low) for the iteration-critical program |
- Implementing the java.util.Set interface, internally backed by a java.util.HashMap instance(permitting null values).
- Making no guarantees to the iteration order and the constantness of the order over time either.
- Not synchronized; must be synchronized externally, for example: Set s = Collections.synchronizedSet(new HashSet());
- Iterators returned by the iterator() method are fail-fast: it will throw a ConcurrentModificationException if the set is modified after the creation of the iterator and by any method except through the iterator's remove() method. Notice that the fail-fast behavior cannot be guaranteed because nothing can be guaranteed in the presence of unsynchronized concurrent modification.
- 实现了java.util.Set接口,内部由java.util.Map示例实现(允许null值)
- 不保证迭代顺序,也不保证迭代顺序一直不变
- 非同步;必须从外部同步,比如:Set s = Collections.synchronizedSet(new HashSet());
- iterator()返回的iterator是fail-fast的:如果这个iterator创建以后,这个set被修改了(不是这个iterator的remove()方法修改的),那么会抛出ConcurrentModificationException异常。(注意,这个fail-fast也是无法保证的,因为在非同步的并发修改中,没有什么是可以保证的)
最新文章
- jq实现点击某元素之外触发事件
- base64和图片的转换
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q63-Q65)
- SharePoint 2010 文档管理之文档推送
- HeadFirst 12 (web应用安全)
- winform 防止多開
- 搜索引擎spam
- Form( 表单) 组件
- 『openframeworks』shader制作三角形马赛克效果
- POJ 3264 RMQ裸题
- Python中的turtle初探
- javaFX笔记----ComboBox模仿qq账号下拉框删除账号
- Vue2.x源码学习笔记-从一个小例子查看vm实例生命周期
- Centos7.0下MySQL的安装
- webserver apache 2.2.22-7/ apache webdav / redhat 6.3
- git 先创建远程库后克隆到本地
- Linux_Crontab命令
- WPF MVVM Style中使用事件
- css readonly和disabled的区别
- SilverLight-DataControls:四、The PagedCollectionView(分页的集合视图) 对象
热门文章
- null与undefined的比较
- Solr7使用Oracle数据源导入+中文分词
- Sagit.Framework For IOS 开发框架入门教程3:Start引导页及框架布局和隐藏事件的内幕
- es6+require混合开发,兼容es6 module,import,export
- 某pdf转word v6.3.0.2算法分析
- POJ 1469(裸二分匹配)
- Oracle自动备份数据
- Solr4.10与tomcat整合并安装中文分词器
- springboot(十五):springboot+jpa+thymeleaf增删改查示例
- androidstudio连接SCM Manager上的Git库