1. [代码]首先是借口定义
* @author xzf
public interface MyDeque<E> {
* insert the specified element at the front of this deque if it is possible
* to do so immediately without violating capacity restrictions.
@param e the element to add
void addFirst(E e);
* insert the specified element at the end of this deque if it is possible
* to do so immediately without violating capacity restrictions.
* @param e the element to add
void addLast(E e);
* @return the head of this deque
E removeFirst();
* @return the tail of this deque
E removeLast();
* insert the specified element into the queue represented by this deque
* (in other words, at the tail of this deque) if it is possible
* to do so immediately without violating capacity restrictions.
* @return true upon success
boolean add(E e);
* retrieve and remove the head of this queue represented by this deque
* (in other words, the first element of this deque).
* @return the head of the queue represented by this deque
* push an element onto the stack represented by this deque
* (in other words, at the head of this deque) if it is possible
to do so immediately without violating capacity restrictions.
* @param e the element to push
void push(E e);
* pop an element from the stack represented by this deque. In other words,
* removes and returns the first element of this deque.
* @return the element at the front of this deque
* return the number of elements of this dceque.
* @return the number of elements of this dceque
2. [代码]自定义LinkedList实现类
view sourceprint?
* @author xzf
* @param <E>
public class MyLinkedList<E> implements MyDeque<E>{
private Entry<E> header;
private int size;
public MyLinkedList()
header = new Entry<E>(null, null, null);
size = 0;
header.next = header.privious = header;
* insert the specified element at the front of this deque if it is possible
* to do so immediately without violating capacity restrictions.
* @param e the element to add
public void addFirst(E e) {
addBefore(e, header.next);
* insert the specified element at the end of this deque if it is possible
* to do so immediately without violating capacity restrictions.
@param e the element to add
public void addLast(E e) {
addBefore(e, header);
* retrieve and remove the first element of this deque.
* @return the head of this deque
public E removeFirst() {
return remove(header.next);
* @return the tail of this deque
public E removeLast() {
return remove(header.privious);
* insert the specified element into the queue represented by this deque
* (in other words, at the tail of this deque) if it is possible
* to do so immediately without violating capacity restrictions.
* @return true upon success
public boolean add(E e) {
addBefore(e, header);http://www.huiyi8.com/jiaoben/ JQuery特效
* retrieve and remove the head of this queue represented by this deque
* (in other words, the first element of this deque).
* @return the head of the queue represented by this deque
public E remove() {
return removeFirst();
* push an element onto the stack represented by this deque
* (in other words, at the head of this deque) if it is possible
* to do so immediately without violating capacity restrictions.
* @param e the element to push

转载于:https://www.cnblogs.com/cjings/p/3819982.html

自定义LinkedList实现相关推荐

  1. 自定义LinkedList

    LinkedList是通过双向链表实现的. 下面实现LinkedList类的以下方法: clear():清空整个链表 size():获取链表的大小 isEmpty():判断链表是否为空 get(int ...

  2. Java - Collection

    Collection层次结构 Collection [plain] view plaincopy print? 子接口 Set,List 集合中只能放置对象的引用,不能放置原生数据类型, 我们需要使用 ...

  3. ArrayList 和 LinkedList 的自定义实现

    文章目录 前言 一.ArrayList 二.LinkedList 总结 前言 下面给出 ArrayList 和 LinkedList 的自定义实现,仅作为练习. 一.ArrayList 自己仿照着写一 ...

  4. 容器类(自定义容器类,List集合,LinkedList,HashSet)小结

    import java.util.Arrays; /* 特点: 1.定长 2.数据类型相同 3.有序数组:存储多个数据 容器类:存储多个数据 自定义容器类 */ public class App { ...

  5. java什么时候用list_Java快问快答:用 ArrayList 还是 LinkedList?

    问题: 通常我会这么定义列表: List names = new ArrayList<>() names类型使用List接口,那么具体实现该如何选择. 什么时候应该用LinkedList替 ...

  6. jsp自定义图文新闻列表标签结合ssh2,带分页功能

    jsp自定义图文新闻列表标签结合ssh2,带分页功能(欢迎大家讨论指点,共同进步) 1.service层 (模拟返回数据) package com.mingda.service.impl;import ...

  7. 从自定义TagLayout看自定义布局的一般步骤[手动加精]

    从自定义TagLayout看自定义布局的一般步骤[手动加精] 我们常用的布局有LinearLayout,FrameLayout,RelativeLayout,大多数情况下都能满足我们的需求,但是也有很 ...

  8. 【Android 应用开发】 自定义组件 宽高适配方法, 手势监听器操作组件, 回调接口维护策略, 绘制方法分析 -- 基于 WheelView 组件分析自定义组件

    博客地址 : http://blog.csdn.net/shulianghan/article/details/41520569 代码下载 : -- GitHub : https://github.c ...

  9. 自定义ServicesLoader来实现根据配置使用不通的SPI实现从而实现项目扩展

    2019独角兽企业重金招聘Python工程师标准>>> 自定义ServicesLoader来实现根据配置使用不通的SPI实现从而实现项目扩展 一 .  都知道Java中的SPI技术, ...

  10. 高并发编程-自定义简易的线程池(2),体会原理

    文章目录 概述 示例 概述 高并发编程-自定义简易的线程池(1),体会原理 中只实现了任务队列,我们这里把其余的几个也补充进来 拒绝策略 关闭线程池 最小 最大 活动线程数 - 示例 比较简单,直接上 ...

最新文章

  1. QCustomplot控件设备背景图片(Qt图片自适应控件大小),并且设置绘图区域颜色透明
  2. Spring JDBC-混合框架的事务管理
  3. Cost Element-成本要素
  4. php 栈、 出栈、入栈
  5. RabbitMQ教程C#版 “Hello World”
  6. css中会计算的属性,2017年12月聚合文章--calc() ---一个会计算的css属性 | 码友网
  7. LeetCode 551. 学生出勤记录 I
  8. 快排的c++实现(两种实现方式)
  9. mysql增加sort_buffer_MySQL数据库之MySQL中的sort_buffer_size参数大小的设置问题
  10. 一些机器学习(Machine Learning)的网站总结
  11. 在几何画板中如何制作圆柱的侧面展开动画_几何画板制作圆锥侧面展开图课件...
  12. 短信工具类 SmsUtil
  13. python画图网格线设置_python – Matplotlib:更改单个网格线的颜色
  14. 申请苹果开发者账号(2016最新版)
  15. 如何做好SQLite 使用质量检测,让事故消灭在摇篮里
  16. Clickhouse打包aarch64二进制文件
  17. 美的智能家电搭载华为鸿蒙系统产品将大批量上市;蔡天乐将出任麦德龙中国总裁 | 美通企业日报...
  18. 无人驾驶运用了什么技术,无人驾驶技术是
  19. html背景音乐音量控制,视频加背景音乐 调小背景音乐音量 这样不影响原视频声音...
  20. 对于大流量网站的流量优化

热门文章

  1. 思科路由器上配置了rip但是没有生成动态路由表_思科路由器 RIP、OSPF、EIGRP 路由协议最简单的配置实例详解...
  2. 安装composer并创建laravel项目流程
  3. html中radio实现互斥
  4. BFS解决连同块问题
  5. 数据结构排序算法思路总结
  6. 第七章思维导图前半段
  7. Apache JMeter web 应用测试工具使用快速入门
  8. Spring 注解 @Controller,@Service,@Repository,@Component,重定向 与 服务端跳转
  9. LayaAir 屏幕适配-分辨率、对齐模式
  10. Spring boot 拦截器(HandlerInterceptor) 与 自定义资源映射虚拟路径,WebMvcConfigurer