7 Star 34 Fork 23

空無一悟/algorithms

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
LinkedListSet.java 1.03 KB
Copy Edit Raw Blame History
空無一悟 authored 2021-09-22 23:47 +08:00 . init
/***********************************************************
* @Description : 基于链表的集合
* @author : 梁山广(Laing Shan Guang)
* @date : 2018/5/17 00:30
* @email : liangshanguang2@gmail.com
***********************************************************/
package Chapter07SetAndMap.Section2LinkedListSet;
import Chapter04LinkedList.Section5Delete.LinkedList;
import Chapter07SetAndMap.Section1SetBasicAndBSTSet.Set;
public class LinkedListSet<E> implements Set<E> {
private LinkedList<E> list;
public LinkedListSet() {
list = new LinkedList<>();
}
@Override
public void add(E e) {
if (!list.contain(e)) {
list.addFirst(e);
}
}
@Override
public void delete(E e) {
list.deleteElement(e);
}
@Override
public boolean contain(E e) {
return list.contain(e);
}
@Override
public int getSize() {
return list.getSize();
}
@Override
public boolean isEmpty() {
return list.isEmpty();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

Search