---
title: "core java 2-2 Collections"
author: "hfhwan"
date: "2010-07-05T16:43:06Z"
tags: ["Cache", "Java", "thread"]
categories: ["编程语言"]
slug: "core-java-2-2-collections"
draft: false
lastmod: "2010-07-05T16:43:06Z"
id: 705976
url: "https://hfhwan.iteye.com/blog/705976"
---

circularArrayQueue (ArrayBlockingQueue)  thread

 

iterator 代替 enumeration

删除两个元素，不能连续remove

 

linkedlist 是双向链表

listIteratorL 多一个previos()

 

不能有多个更改list的iterator在操作。（添加删除，set()方法除外）

iterator的add()方法之和位置有关，remove()方法和状态有关（next(),previous()）

 

————————————————————————————————————————————————

hashset

如果两个对象的equals()，他们必须有相同的hashcode();

comparator&lt;T&gt;接口有两个方法。equals()，不需要重写。（why）

 

hashset 哈希表

treeSet  红黑树

PriorityQueue  heap （iterator无序，取出最最小）

 

——————————————————————————————————————————————————

map:

keySet()   (实现了set接口的特殊集合类）

entrySet()  entry，map的内部类

values(); 不是set，是什么呢？

 

WeakHahMap  （弱引用） 用来解决没有引用的key对应的enty值的回收问题

linkedHashMap or sets： removeEldestEntry  （最近访问值， accessorder）做cache

EnumSet （专门针对Enum类型的set） bit来表示，效率。

IdentityHashMap （利用对象的内存地址作为key，==）