一天一个类,一点也不累 之 Set接口
2015-04-23 20:05
197 查看
我们的口号是:一天一个类,一点也不累~~
再次回忆一下集合相关的类图。
官方API上这样介绍这个接口:
A collection that contains no duplicate elements. More formally, sets contain no pair of elements
这个集合类不能容纳有复制品的元素,也就是不存在两个元素相等(equals),充其量存在一个NULL元素。
他提供的一些方法如下:
int size();
boolean isEmpty();
boolean contains(Object o);
Iterator<E> iterator();
Object[] toArray();
<T> T[] toArray(T[] a);
boolean add(E e);
boolean remove(Object o);
boolean containsAll(Collection<?> c);
boolean addAll(Collection<? extends E> c);
boolean retainAll(Collection<?> c);
boolean removeAll(Collection<?> c);
void clear();
boolean equals(Object o);
int hashCode();
而这些方法需要实现类来实现具体的操作。
再次回忆一下集合相关的类图。
官方API上这样介绍这个接口:
A collection that contains no duplicate elements. More formally, sets contain no pair of elements
e1and
e2such that
e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.
这个集合类不能容纳有复制品的元素,也就是不存在两个元素相等(equals),充其量存在一个NULL元素。
他提供的一些方法如下:
int size();
boolean isEmpty();
boolean contains(Object o);
Iterator<E> iterator();
Object[] toArray();
<T> T[] toArray(T[] a);
boolean add(E e);
boolean remove(Object o);
boolean containsAll(Collection<?> c);
boolean addAll(Collection<? extends E> c);
boolean retainAll(Collection<?> c);
boolean removeAll(Collection<?> c);
void clear();
boolean equals(Object o);
int hashCode();
而这些方法需要实现类来实现具体的操作。
相关文章推荐
- 一天一个类,一点也不累 之 Vector
- 一天一个类,一点也不累之HashSet
- 一天一个类,一点也不累之TreeSet
- 一天一个类,一点也不累 之 LinkedList
- [一天一点java]一个简单的计数器
- linux一天一个命令--解压tgz文件
- 一天一个设计模式---解释器模式
- 读《那些年,那些事 一个程序猿的奋斗史》 一点自己的感触
- 一天一点学习Linux之在RHEL6系统上配置磁盘阵列(RAID)
- 一天一个linux基础命令之时间日期命令date 推荐
- 一个菜鸟作的一点汇编笔记
- 项目功能大全,让你的项目一天搞定(给新手们一点干货)
- 一个『瘦猴』对产品的一点看法
- 不要怀疑---这就是你,一个中国人,过的完整的一天...
- 【一天一个shell命令】文件内容操作系列-cat
- 关于major和无人驾驶的一点想法(写给一个微信群)
- 一个老程序员的一天(转载,我还是猜鸟呢,嘿嘿)
- 一天一个shell命令 linux文本内容操作系列-grep命令详解
- java 已知一个Date(),获取前一天和后一天
- 在2006年的最后一天,我做出了一个决定