二十三、剖析 LinkedList

news2024/9/24 6:02:25

剖析 LinkedList

本文为书籍《Java编程的逻辑》1和《剑指Java:核心原理与应用实践》2阅读笔记

ArrayList随机访问效率很高,但插入和删除性能比较低;LinkedList同样实现了List接口,它的特点与ArrayList几乎正好相反。除了实现了List接口外,LinkedList还实现了DequeQueue接口,可以按照队列、栈和双端队列的方式进行操作。

2.1 基本用法

LinkedList有两个构造方法:

public LinkedList()
public LinkedList(Collection<? extends E> c)

所以,可以按照下面两种方法创建LinkedList对象:

List<String> list = new LinkedList<>();
List<String> list2 = new LinkedList<>(Arrays.asList(new String[]{"a", "b", "c"}));

ArrayList一样,LinkedList同样实现了List接口,而List接口扩展了Collection接口,Collection又扩展了Iterable接口,所有这些接口的方法都是可以使用的,使用方法与ArrayList介绍的一样。

ArrayList不同的是,LinkedList实现了队列接口Queue,所谓队列就类似于日常生活中的各种排队,特点就是先进先出,在尾部添加元素,从头部删除元素,它的接口定义为:

public interface Queue<E> extends Collection<E> {
    /**
     * Inserts the specified element into this queue if it is possible to do so
     * immediately without violating capacity restrictions, returning
     * {@code true} upon success and throwing an {@code IllegalStateException}
     * if no space is currently available.
     *
     * @param e the element to add
     * @return {@code true} (as specified by {@link Collection#add})
     * @throws IllegalStateException if the element cannot be added at this
     *         time due to capacity restrictions
     * @throws ClassCastException if the class of the specified element
     *         prevents it from being added to this queue
     * @throws NullPointerException if the specified element is null and
     *         this queue does not permit null elements
     * @throws IllegalArgumentException if some property of this element
     *         prevents it from being added to this queue
     */
    boolean add(E e);

    /**
     * Inserts the specified element into this queue if it is possible to do
     * so immediately without violating capacity restrictions.
     * When using a capacity-restricted queue, this method is generally
     * preferable to {@link #add}, which can fail to insert an element only
     * by throwing an exception.
     *
     * @param e the element to add
     * @return {@code true} if the element was added to this queue, else
     *         {@code false}
     * @throws ClassCastException if the class of the specified element
     *         prevents it from being added to this queue
     * @throws NullPointerException if the specified element is null and
     *         this queue does not permit null elements
     * @throws IllegalArgumentException if some property of this element
     *         prevents it from being added to this queue
     */
    boolean offer(E e);

    /**
     * Retrieves and removes the head of this queue.  This method differs
     * from {@link #poll() poll()} only in that it throws an exception if
     * this queue is empty.
     *
     * @return the head of this queue
     * @throws NoSuchElementException if this queue is empty
     */
    E remove();

    /**
     * Retrieves and removes the head of this queue,
     * or returns {@code null} if this queue is empty.
     *
     * @return the head of this queue, or {@code null} if this queue is empty
     */
    E poll();

    /**
     * Retrieves, but does not remove, the head of this queue.  This method
     * differs from {@link #peek peek} only in that it throws an exception
     * if this queue is empty.
     *
     * @return the head of this queue
     * @throws NoSuchElementException if this queue is empty
     */
    E element();

    /**
     * Retrieves, but does not remove, the head of this queue,
     * or returns {@code null} if this queue is empty.
     *
     * @return the head of this queue, or {@code null} if this queue is empty
     */
    E peek();
}

Queue扩展了Collection,它的主要操作有三个:

  1. 在尾部添加元素(addoffer);
  2. 查看头部元素(elementpeek),返回头部元素,但不改变队列;
  3. 删除头部元素(removepoll),返回头部元素,并且从队列中删除。

每种操作都有两种形式,有什么区别呢?区别在于,对于特殊情况的处理不同。特殊情况是指队列为空或者队列为满,为空容易理解,为满是指队列有长度大小限制,而且已经占满了。LinkedList的实现中,队列长度没有限制,但别的Queue的实现可能有。在队列为空时,elementremove会抛出异常NoSuchElementException,而peekpoll返回特殊值null;在队列为满时,add会抛出异常IllegalStateException,而offer只是返回false

除了QueueLinkedList还可以当成栈,栈也是一种常用的数据结构,与队列相反,它的特点是先进后出、后进先出,类似于一个储物箱,放的时候是一件件往上放,拿的时候则只能从上面开始拿。Java中没有单独的栈接口,栈相关方法包括在了表示双端队列的接口Deque中,主要有三个方法:

void push(E e);
E pop();
E peek();

解释如下。

  1. push表示入栈,在头部添加元素,栈的空间可能是有限的,如果栈满了,push会抛出异常IllegalStateException
  2. pop表示出栈,返回头部元素,并且从栈中删除,如果栈为空,会抛出异常NoSuchElementException
  3. peek查看栈头部元素,不修改栈,如果栈为空,返回null。

讲到栈,Java中有一个类Stack,单词意思就是栈,它也实现了栈的一些方法,如push/pop/peek等,但它没有实现Deque接口,它是Vector的子类,它增加的这些方法也通过synchronized实现了线程安全,具体就不介绍了。不需要线程安全的情况下,推荐使用LinkedListArrayDeque

栈和队列都是在两端进行操作,栈只操作头部,队列两端都操作,但尾部只添加、头部只查看和删除。结合队列和栈,有一个更为通用的操作两端的接口DequeDeque扩展了Queue,包括了栈的操作方法,此外,它还有如下更为明确的操作两端的方法:

void addFirst(E e);
void addLast(E e);
E getFirst();
E getLast();
boolean offerFirst(E e);
boolean offerLast(E e);
E peekFirst();
E peekLast();
E pollFirst();
E pollLast();
E removeFirst();
E removeLast();

xxxFirst操作头部,xxxLast操作尾部。与队列类似,每种操作有两种形式,区别也是在队列为空或满时处理不同。为空时,getXXX/removeXXX会抛出异常,而peekXXX/pollXXX会返回null。队列满时,addXXX会抛出异常,offerXXX只是返回false

栈和队列只是双端队列的特殊情况,它们的方法都可以使用双端队列的方法替代,不过,使用不同的名称和方法,概念上更为清晰。

Deque接口还有一个迭代器方法,可以从后往前遍历:

    /**
     * Returns an iterator over the elements in this deque in reverse
     * sequential order.  The elements will be returned in order from
     * last (tail) to first (head).
     *
     * @return an iterator over the elements in this deque in reverse
     * sequence
     */
    Iterator<E> descendingIterator();

简单总结下:LinkedList的用法是比较简单的,与ArrayList用法类似,支持List接口,只是,LinkedList增加了一个接口Deque,可以把它看作队列、栈、双端队列,方便地在两端进行操作。如果只是用作List,那应该用ArrayList还是LinkedList呢?我们需要了解LinkedList的实现原理,根据实际需要再作决定。

2.2 实现原理

1、内部组成

我们知道,ArrayList内部是数组,元素在内存是连续存放的,但LinkedList不是。LinkedList直译就是链表,确切地说,它的内部实现是双向链表,每个元素在内存都是单独存放的,元素之间通过链接连在一起,类似于小朋友之间手拉手一样。

为了实现链表,LinkedList定义了一个s私有静态内部类 – 节点(Node),代码如下所示:

    private static class Node<E> {
        E item;
        Node<E> next;
        Node<E> prev;

        Node(Node<E> prev, E element, Node<E> next) {
            this.item = element;
            this.next = next;
            this.prev = prev;
        }
    }

节点包括实际的元素E item,但同时有两个链接,分别指向前一个节点(前驱,Node<E> prev)和后一个节点(后继,Node<E> next)。

LinkedList内部组成就是如下三个实例变量:

transient int size = 0;

/**
 * Pointer to first node.
 */
transient Node<E> first;

/**
 * Pointer to last node.
 */
transient Node<E> last;

size表示链表长度,默认为 0 0 0first指向头节点,last指向尾节点,初始值都为null

LinkedList的所有public方法内部操作的都是这三个实例变量,具体是怎么操作的?链接关系是如何维护的?我们看一些主要的方法,分别分析。

2、add 方法

add方法代码如下:

    /**
     * Appends the specified element to the end of this list.
     *
     * <p>This method is equivalent to {@link #addLast}.
     *
     * @param e element to be appended to this list
     * @return {@code true} (as specified by {@link Collection#add})
     */
    public boolean add(E e) {
        linkLast(e);
        return true;
    }

代码中,主要调用了linkLast方法,代码如下:

    /**
     * Links e as last element.
     */
    void linkLast(E e) {
        final Node<E> l = last;
        final Node<E> newNode = new Node<>(l, e, null);
        last = newNode;
        if (l == null)
            first = newNode;
        else
            l.next = newNode;
        size++;
        modCount++;
    }

linkLast代码的基本步骤如下。

  1. 创建一个新的节点newNodellast指向原来的尾节点,如果原来链表为空,则为null。代码为:

    final Node<E> l = last;
    final Node<E> newNode = new Node<>(l, e, null);
    
  2. 修改尾节点last,指向新的最后节点newNode。代码为:

    last = newNode;
    
  3. 修改前节点的后向链接,如果原来链表为空,则让头节点指向新节点,否则让前一个节点的next指向新节点。代码为:

    if (l == null)
        first = newNode;
    else
        l.next = newNode;
    
  4. 增加链表大小和修改计数器。代码为:

    size++;
    modCount++;
    

接下来,通过图示加深LinkedList添加元素过程的理解:

List<String> list = new LinkedList<String>();
list.add("a");
list.add("b");

执行完List<String> list = new LinkedList<String>()后,LinkedList内部结果如下所示:

在这里插入图片描述

添加a后,LinkedList内部结果如下所示:

在这里插入图片描述

添加b后,LinkedList内部结果如下所示:

在这里插入图片描述

可以看出,与ArrayList不同,LinkedList的内存是按需分配的,不需要预先分配多余的内存,添加元素只需分配新元素的空间,然后调节几个链接即可。

3、根据索引访问元素 get

LinkedListArrayList一样,支持根据索引值访问元素,代码如下:

    /**
     * Returns the element at the specified position in this list.
     *
     * @param index index of the element to return
     * @return the element at the specified position in this list
     * @throws IndexOutOfBoundsException {@inheritDoc}
     */
    public E get(int index) {
        checkElementIndex(index);
        return node(index).item;
    }

checkElementIndex检查索引位置的有效性,如果无效,则抛出异常,代码为:

    private void checkElementIndex(int index) {
        if (!isElementIndex(index))
            throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
    }
    /**
     * Tells if the argument is the index of an existing element.
     */
    private boolean isElementIndex(int index) {
        return index >= 0 && index < size;
    }

如果index有效,则传入参数index调用node方法查找对应的节点,其item属性就指向实际元素内容,node方法的代码为:

    /**
     * Returns the (non-null) Node at the specified element index.
     */
    Node<E> node(int index) {
        // assert isElementIndex(index);

        if (index < (size >> 1)) {
            Node<E> x = first;
            for (int i = 0; i < index; i++)
                x = x.next;
            return x;
        } else {
            Node<E> x = last;
            for (int i = size - 1; i > index; i--)
                x = x.prev;
            return x;
        }
    }

size>>1等于size/2,如果索引位置在前半部分(index<(size>>1)),则从头节点开始查找,否则,从尾节点开始查找。可以看出,与ArrayList明显不同,ArrayList中数组元素连续存放,可以根据索引直接定位,而在LinkedList中,则必须从头或尾顺着链接查找,效率比较低。

4、根据内容查找元素索引 indexOf

    /**
     * Returns the index of the first occurrence of the specified element
     * in this list, or -1 if this list does not contain the element.
     * More formally, returns the lowest index {@code i} such that
     * {@code Objects.equals(o, get(i))},
     * or -1 if there is no such index.
     *
     * @param o element to search for
     * @return the index of the first occurrence of the specified element in
     *         this list, or -1 if this list does not contain the element
     */
    public int indexOf(Object o) {
        int index = 0;
        if (o == null) {
            for (Node<E> x = first; x != null; x = x.next) {
                if (x.item == null)
                    return index;
                index++;
            }
        } else {
            for (Node<E> x = first; x != null; x = x.next) {
                if (o.equals(x.item))
                    return index;
                index++;
            }
        }
        return -1;
    }

代码也很简单,从头节点顺着链接往后找,如果要找的是null,则找第一个itemnull的节点,否则使用equals方法进行比较。

5、插入元素 add(int, E)

add()在尾部添加元素,如果在头部或者中间插入元素呢?可以使用add(int index, E element)方法,代码如下:

    /**
     * Inserts the specified element at the specified position in this list.
     * Shifts the element currently at that position (if any) and any
     * subsequent elements to the right (adds one to their indices).
     *
     * @param index index at which the specified element is to be inserted
     * @param element element to be inserted
     * @throws IndexOutOfBoundsException {@inheritDoc}
     */
    public void add(int index, E element) {
        checkPositionIndex(index);

        if (index == size)
            linkLast(element);
        else
            linkBefore(element, node(index));
    }

如果indexsize,添加到最后面,一般情况,是插入到index对应节点的前面,调用方法为linkBefore,它的代码为:

    /**
     * Inserts element e before non-null Node succ.
     */
    void linkBefore(E e, Node<E> succ) {
        // assert succ != null;
        final Node<E> pred = succ.prev;
        final Node<E> newNode = new Node<>(pred, e, succ);
        succ.prev = newNode;
        if (pred == null)
            first = newNode;
        else
            pred.next = newNode;
        size++;
        modCount++;
    }

参数succ表示后继节点,变量pred表示前驱节点,目标是在predsucc中间插入一个节点。插入步骤是:

  1. 新建一个节点newNode,前驱为pred,后继为succ。代码为:

    final Node<E> pred = succ.prev;
    final Node<E> newNode = new Node<>(pred, e, succ);
    
  2. 让后继的前驱指向新节点。代码为:

    succ.prev = newNode;
    
  3. 让前驱的后继指向新节点,如果前驱为空,那么修改头节点指向新节点。代码为:

    if (pred == null)
        first = newNode;
    else
        pred.next = newNode;
    
  4. 增加长度和修改计数器。

我们通过图示来进行介绍。还是上面的例子,比如,插入一个元素:

list.add(1, "c");

内存结构如下图所示:

在这里插入图片描述

可以看出,在中间插入元素,LinkedList只需按需分配内存,修改前驱和后继节点的链接,而ArrayList则可能需要分配很多额外空间,且移动所有后续元素。

6、删除元素 remove(int) 和 remove(Object)

我们再来看删除元素,首先看remove(int),代码如下为:

    public E remove(int index) {
        checkElementIndex(index);
        return unlink(node(index));
    }

remove(Object),代码如下:

	public boolean remove(Object o) {
        if (o == null) {
            for (Node<E> x = first; x != null; x = x.next) {
                if (x.item == null) {
                    unlink(x);
                    return true;
                }
            }
        } else {
            for (Node<E> x = first; x != null; x = x.next) {
                if (o.equals(x.item)) {
                    unlink(x);
                    return true;
                }
            }
        }
        return false;
    }

查看代码,可以知道,删除某个节点时,都是先找到待删除的节点,随后调用unlink(Node)方法,代码如下:

    E unlink(Node<E> x) {
        // assert x != null;
        final E element = x.item;
        final Node<E> next = x.next;
        final Node<E> prev = x.prev;

        if (prev == null) {
            first = next;
        } else {
            prev.next = next;
            x.prev = null;
        }

        if (next == null) {
            last = prev;
        } else {
            next.prev = prev;
            x.next = null;
        }

        x.item = null;
        size--;
        modCount++;
        return element;
    }

删除x节点,基本思路就是让x的前驱和后继直接链接起来,nextx的后继,prevx的前驱,具体分为两步。

  1. x的前驱的后继指向x的后继。如果x没有前驱,说明删除的是头节点,则修改头节点指向x的后继。
  2. x的后继的前驱指向x的前驱。如果x没有后继,说明删除的是尾节点,则修改尾节点指向x的前驱。

通过图示进行说明。还是上面的例子,如果删除一个元素:

list.remove(1);

内存结构如下图所示:

在这里插入图片描述

2.3 LinkedList 特点分析

用法上,LinkedList是一个List,但也实现了Deque接口,可以作为队列、栈和双端队列使用。实现原理上,LinkedList内部是一个双向链表,并维护了长度、头节点和尾节点,这决定了它有如下特点。

  1. 按需分配空间,不需要预先分配很多空间。
  2. 不可以随机访问,按照索引位置访问效率比较低,必须从头或尾顺着链接找,效率为 O ( N 2 ) O(\frac{N}{2}) O(2N)
  3. 不管列表是否已排序,只要是按照内容查找元素,效率都比较低,必须逐个比较,效率为 O ( N ) O(N) O(N)
  4. 在两端添加、删除元素的效率很高,为 O ( 1 ) O(1) O(1)
  5. 在中间插入、删除元素,要先定位,效率比较低,为 O ( N ) O(N) O(N),但修改本身的效率很高,效率为 O ( 1 ) O(1) O(1)

理解了LinkedListArrayList的特点,就能比较容易地进行选择了,如果列表长度未知,添加、删除操作比较多,尤其经常从两端进行操作,而按照索引位置访问相对比较少,则LinkedList是比较理想的选择。


  1. 马俊昌.Java编程的逻辑[M].北京:机械工业出版社,2018. ↩︎

  2. 尚硅谷教育.剑指Java:核心原理与应用实践[M].北京:电子工业出版社,2023. ↩︎

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1487095.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【CSP试题回顾】201709-1-打酱油

CSP-201709-1-打酱油 完整代码 #include<iostream> using namespace std; int main() {int N, num 0;cin >> N;int n1 N / 50;if (n1 ! 0){N N - n1 * 50;num n1 * 7;}int n2 N / 30;if (n2 ! 0){N N - n2 * 30;num n2 * 4;}int n3 N / 10;num n3;cout…

幂等性设计

目录 前言 幂等性设计 幂等性设计处理流程 HTTP 幂等性 消息队列幂等性 机遇kafka 前言 幂等性设计&#xff0c;就是说&#xff0c;一次和多次请求某一个资源应该具有同样的副作用。为什么我们要有幂等性操作&#xff1f;说白了&#xff0c;就两点&#xff1a;1、网络的…

品牌作为储蓄池:静态积累与长期价值

在瞬息万变的商业环境中&#xff0c;品牌不仅仅是一个简单的标识或名字&#xff0c;它更像是一个融合了静态积累与长期价值的综合储蓄池。品牌通过不断的积累&#xff0c;建立起深厚的市场基础和消费者信任&#xff0c;这些无形的资产为品牌的长期发展奠定了坚实的基础。品牌推…

【大厂AI课学习笔记NO.59】(12)过拟合与欠拟合

拟合就是调整参数和模型&#xff0c;让结果无限接近真实值的过程。 我们先来了解个概念&#xff1a; 偏差-方差窘境&#xff08;bias-variance dilemma&#xff09;是机器学习中的一个重要概念&#xff0c;它涉及到模型选择时面临的权衡问题。 偏差&#xff08;Bias&#xf…

【二分查找】【C++算法】378. 有序矩阵中第 K 小的元素

作者推荐 视频算法专题 本文涉及的基础知识点 二分查找算法合集 LeetCode378. 有序矩阵中第 K 小的元素 给你一个 n x n 矩阵 matrix &#xff0c;其中每行和每列元素均按升序排序&#xff0c;找到矩阵中第 k 小的元素。 请注意&#xff0c;它是 排序后 的第 k 小元素&…

ubuntu安裝Avahi发现服务工具

一、简介 解决设置固定ip后无法连接外网的问题&#xff0c;目前采用动态获取ip&#xff0c;可以不用设置设备的固定IP&#xff0c;直接可以通过域名来访问设备&#xff0c;类似树莓派的连接调试 二、安装 本文使用的是ubuntu23.10.1上安装 1.安装工具 sudo apt install av…

展览展会媒体传播的必要性,有哪些宣传方式?

传媒如春雨&#xff0c;润物细无声&#xff0c;大家好&#xff0c;我是51媒体网胡老师。 展览展会媒体传播的必要性在于扩大影响力、吸引观众和促进行业交流。通过媒体宣传&#xff0c;可以快速传递展会信息&#xff0c;提升品牌知名度&#xff0c;吸引更多潜在参展商和观众。…

【C语言】linux内核packet_setsockopt

一、中文注释 // 发送数据包函数。它尝试通过特定的网络设备队列直接传输一个skb&#xff08;socket缓冲区&#xff09;。 static int packet_direct_xmit(struct sk_buff *skb) {return dev_direct_xmit(skb, packet_pick_tx_queue(skb)); // 调用dev_direct_xmit函数&#x…

上位机图像处理和嵌入式模块部署(上、下位机通信的三个注意点)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 如果最终部署在客户现场的是一个嵌入式设备&#xff0c;那么上位机在做好了算法编辑和算法部署之后&#xff0c;很重要的一步就是处理上位机和下位…

Intel FPGA IP之LVDS SerDes IP学习

FPGA 视频数据输入输出直通工程&#xff1a; 屏&#xff1a;13.2吋8bit色深&#xff0c;屏幕分辨率为1440*192060&#xff0c;具有两个Port&#xff0c;每个Port有4个差分数据对与1个差分时钟对&#xff0c;差分对均支持LVDS协议芯片&#xff1a;Cyclone V系列FPGA目的&#x…

分布式ID生成策略-雪花算法Snowflake

分布式ID生成策略-雪花算法Snowflake 一、其他分布式ID策略1.UUID2.数据库自增与优化2.1 优化1 - 共用id自增表2.2 优化2 - 分段获取id 3.Reids的incr和incrby 二、雪花算法Snowflake1.雪花算法的定义2.基础雪花算法源码解读3.并发1000测试4.如何设置机房和机器id4.雪花算法时钟…

在Ubuntu22.04安装Fcitx5中文输入法教程(十分详细)

前言 书接上回&#xff0c;一时兴起将主力机的 Ubuntu 20.04 LTS 升级至了刚刚发布的 22.04 LTS。从 X 切换到 Wayland 、GNOME 从 3.36 升级至 42、Python 默认为 3.10 等等……使用太新的软件包反而暂时带来了麻烦&#xff0c;部分原有的软件和插件都不可用了。这其中就包括…

浅谈马尔科夫链蒙特卡罗方法(MCMC)算法的理解

1.解决的问题 计算机怎么在任意给定的概率分布P上采样&#xff1f;首先可以想到把它拆成两步&#xff1a; &#xff08;1&#xff09;首先等概率的从采样区间里取一个待定样本x&#xff0c;并得到它的概率为p(x) &#xff08;2&#xff09;然后在均匀分布U[0,1]上取一个值&a…

可视化管理的kanban插件 | Obsidian实践

继上一篇文章之后&#xff0c;有朋友提问说&#xff1a; 刚好&#xff0c;关于kanban插件的素材&#xff0c;是之前一早就准备好的&#xff0c;便快速整理成文&#xff0c;简单分享一下个人实践。 Prompt&#xff1a;项目流程管理看板&#xff0c;色彩鲜艳。by 通义万象 看板管…

C++调用lua函数

C 调用Lua全局变量(普通) lua_getglobal(lua, "width");int width lua_tointeger(lua,-1);lua_pop(lua,1);std::cout << width << std::endl;lua_close(lua); 这几行代码要放到lua_pcall(lua, 0,0,0);之后才可以. C给lua传递变量 lua_pushstring(lua, …

三、低代码平台-单据配置(单表增删改查)

一、业务效果图 主界面 二、配置过程简介 配置流程&#xff1a;业务表设计 -》业务对象建立-》业务单据配置-》菜单配置。 a、业务表设计 b、业务对象建立 c、业务单据配置 功能路径&#xff1a;低代码开发平台/业务开发配置/单据配置维护 d、菜单配置

【JavaEE】_Spring MVC 项目传参问题

目录 1. 传递单个参数 1.1 关于参数名的问题 2. 传递多个参数 2.1 关于参数顺序的问题 2.2 关于基本类型与包装类的问题 3. 使用对象传参 4. 后端参数重命名问题 4.1 关于RequestPara注解 1. 传递单个参数 现创建Spring MVC项目&#xff0c;.java文件内容如下&#xff…

【k8s存储--使用OpenEBS做持久化存储】

1、简介 使用OpenEBS&#xff0c;你可以将有持久化数据的容器&#xff0c;像对待其他普通容器一样来对待。OpenEBS本身也是通过容器来部署的&#xff0c;支持Kubernetes、Swarm、Mesos、Rancher编排调度&#xff0c;存储服务可以分派给每个pod、应用程序、集群或者容器级别&am…

Mybatis plus拓展功能-JSON处理器

目录 1 前言 2 使用方法 2.1 定义json实体类 2.2 在实体类中使用 1 前言 这是我最近学到的比较新奇的一个东西&#xff0c;数据库居然还可以存储JSON格式的数据&#xff0c;如下。虽然我感觉一般也没谁会这样干&#xff0c;但是既然有&#xff0c;那就当个科普讲一下Mybat…

【自然语言处理】NLP入门(三):1、正则表达式与Python中的实现(3):字符转义符及进制转换

文章目录 一、前言二、正则表达式与Python中的实现1.字符串构造2. 字符串截取3. 字符串格式化输出4. 字符转义符a. 常用字符转义符续行符换行符制表符双引号单引号反斜杠符号回车符退格符 b. ASCII编码转义字符进制转换2 进制8 进制10 进制16 进制进制转换函数 c. Unicode字符\…