import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static java.util.Collections.addAll;
public class HashSetTest {
HashMap map;
private static final Object PRESENT = new Object();
public HashSetTest(){
map = new HashMap(10);
}
public void HashSetTest(Collection c){
addAll(c);
}
public void add(Object o){
map.put(o,PRESENT);
}
public int size(){
return map.size();
}
public void remove(Object o){
map.remove(o);
}
public void clear(){map.clear();}
}
HashSet的简单实现原理
最新推荐文章于 2019-05-22 20:36:34 发布