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.
  1. 实现了java.util.Set接口,内部由java.util.Map示例实现(允许null值)
  2. 不保证迭代顺序,也不保证迭代顺序一直不变
  3. 非同步;必须从外部同步,比如:Set s = Collections.synchronizedSet(new HashSet());
  4. iterator()返回的iterator是fail-fast的:如果这个iterator创建以后,这个set被修改了(不是这个iterator的remove()方法修改的),那么会抛出ConcurrentModificationException异常。(注意,这个fail-fast也是无法保证的,因为在非同步的并发修改中,没有什么是可以保证的)

最新文章

  1. jq实现点击某元素之外触发事件
  2. base64和图片的转换
  3. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q63-Q65)
  4. SharePoint 2010 文档管理之文档推送
  5. HeadFirst 12 (web应用安全)
  6. winform 防止多開
  7. 搜索引擎spam
  8. Form( 表单) 组件
  9. 『openframeworks』shader制作三角形马赛克效果
  10. POJ 3264 RMQ裸题
  11. Python中的turtle初探
  12. javaFX笔记----ComboBox模仿qq账号下拉框删除账号
  13. Vue2.x源码学习笔记-从一个小例子查看vm实例生命周期
  14. Centos7.0下MySQL的安装
  15. webserver apache 2.2.22-7/ apache webdav / redhat 6.3
  16. git 先创建远程库后克隆到本地
  17. Linux_Crontab命令
  18. WPF MVVM Style中使用事件
  19. css readonly和disabled的区别
  20. SilverLight-DataControls:四、The PagedCollectionView(分页的集合视图) 对象

热门文章

  1. null与undefined的比较
  2. Solr7使用Oracle数据源导入+中文分词
  3. Sagit.Framework For IOS 开发框架入门教程3:Start引导页及框架布局和隐藏事件的内幕
  4. es6+require混合开发,兼容es6 module,import,export
  5. 某pdf转word v6.3.0.2算法分析
  6. POJ 1469(裸二分匹配)
  7. Oracle自动备份数据
  8. Solr4.10与tomcat整合并安装中文分词器
  9. springboot(十五):springboot+jpa+thymeleaf增删改查示例
  10. androidstudio连接SCM Manager上的Git库