>>分享Java编程技术,对《Java面向对象编程》等书籍提供技术支持 书籍支持  卫琴直播  品书摘要  在线测试  资源下载  联系我们
发表一个新主题 开启一个新投票 回复文章 您是本文章第 21667 个阅读者 刷新本主题
 * 贴子主题:  JAVA常用数据结构 回复文章 点赞(0)  收藏  
作者:flybird    发表时间:2020-02-04 17:41:41     消息  查看  搜索  好友  邮件  复制  引用

                                                                                                

JAVA常用数据结构

背景

     所有JAVA开发工程师在日常开发工作中,离不开JAVA常用数据结构,比如List、Map、Set等。对其内部原理的了解能够更好地理解这些数据结构的适用场合,避免使用不当引发的诡异问题。本文将对这些常用的JAVA中的数据结构进行一个简单的介绍。    

JAVA中的数据结构简述

     JAVA中常用的数据结构主要有这样几种分类:

         1. List:可存储相同的值(确切讲是a.equals(b)时,二者都可存储)。我们会挑选适宜连续存储的ArrayList和链式存储的LinkedList进行介绍。

         2. Set:不可存储相同值。挑选线程不安全的HashSet和线程安全的ConcurrentHashSet进行介绍。

         3. Map:存储key-value形式的数据。挑选线程不安全的HashMap和线程安全的ConcurrentHashMap进行介绍。    

List

名称 特点 适用场合 不适用的场合
ArrayList 内部采用数组顺序存储 1.       数据连续写入,需要根据index进行查找;

    
2.       按index写入和删除少
需要按index写入数据或删除
LinkedList 采用链表进行存储 1.       数据需要按index插入或删除;

    
2.       按index查找少
需要根据index进行查找

ArrayList

主要属性

  1.         /**
  2.            * The array buffer into which the elements of the ArrayList are stored.
  3.            * The capacity of the ArrayList is the length of this array buffer. Any
  4.            * empty ArrayList with elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA
  5.            * will be expanded to DEFAULT_CAPACITY when the first element is added.
  6.            */
  7.           transient Object[] elementData;  // non-private to simplify nested class access
  8.            /**
  9.            * The size of the ArrayList (the number of elements it contains).
  10.            *
  11.            *  @serial
  12.            */
  13.           private  int size;

       elementData用于存储数据,size用于标识其存储的元素个数。    

构造函数

     共有三种构造函数。

         无参数构造函数,元素存储数组设置为为空数组,初始size为10。        

  1.            /**
  2.            * Constructs an empty list with an initial capacity of ten.
  3.            */
  4.            public  ArrayList () {
  5.               this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;
  6.          }

       给定元素初始个数的构造函数,以传入的initialCapacity为数组长度,创建数组。如果开发者在创建ArrayList的时候,能够预估元素个数,建议采用这个构造函数。原因是可在构造函数中,创建足够长度的数组,而不是在添加元素的时候,再去扩充数组长度。        

  1.          /**
  2.            * Constructs an empty list with the specified initial capacity.
  3.            *
  4.            *  @param  initialCapacity  the initial capacity of the list
  5.            *  @throws IllegalArgumentException if the specified initial capacity
  6.            *         is negative
  7.            */
  8.            public  ArrayList ( int initialCapacity) {
  9.               if (initialCapacity >  0) {
  10.                   this.elementData =  new Object[initialCapacity];
  11.              }  else  if (initialCapacity ==  0) {
  12.                   this.elementData = EMPTY_ELEMENTDATA;
  13.              }  else {
  14.                   throw  new IllegalArgumentException( "Illegal Capacity: "+
  15.                                                     initialCapacity);
  16.              }
  17.          }

       拷贝构造函数        

  1.          /**
  2.            * Constructs a list containing the elements of the specified
  3.            * collection, in the order they are returned by the collection's
  4.            * iterator.
  5.            *
  6.            *  @param c the collection whose elements are to be placed into this list
  7.            *  @throws NullPointerException if the specified collection is null
  8.            */
  9.            public  ArrayList (Collection<? extends E> c) {
  10.              elementData = c.toArray();
  11.               if ((size = elementData.length) !=  0) {
  12.                   // c.toArray might (incorrectly) not return Object[] (see 6260652)
  13.                   if (elementData.getClass() != Object[].class)
  14.                      elementData = Arrays.copyOf(elementData, size, Object[].class);
  15.              }  else {
  16.                   // replace with empty array.
  17.                   this.elementData = EMPTY_ELEMENTDATA;
  18.              }
  19.          }

根据index添加、删除、获取元素

     根据index添加元素:        

  1.            /**
  2.            * Inserts the specified element at the specified position in this
  3.            * list. Shifts the element currently at that position (if any) and
  4.            * any subsequent elements to the right (adds one to their indices).
  5.            *
  6.            *  @param index index at which the specified element is to be inserted
  7.            *  @param element element to be inserted
  8.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  9.            */
  10.            public  void  add ( int index, E element) {
  11.              rangeCheckForAdd(index);
  12.              ensureCapacityInternal(size +  1);   // Increments modCount!!
  13.              System.arraycopy(elementData, index, elementData, index +  1,
  14.                               size - index);
  15.              elementData[index] = element;
  16.              size++;
  17.          }

       从代码中不难看出,首先检查index是否存在越界问题,接下来检查数组容量(如果超过了默认的10,需要做数组容量扩展,扩展50%),最后在index位置插入给定的元素,并将原有index位置到size-1位置的元素向后挪一个位置,将size+1。

         根据index删除元素:        

  1.        /**
  2.            * Removes the element at the specified position in this list.
  3.            * Shifts any subsequent elements to the left (subtracts one from their
  4.            * indices).
  5.            *
  6.            *  @param index the index of the element to be removed
  7.            *  @return the element that was removed from the list
  8.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  9.            */
  10.            public E  remove ( int index) {
  11.              rangeCheck(index);
  12.              modCount++;
  13.              E oldValue = elementData(index);
  14.               int numMoved = size - index -  1;
  15.               if (numMoved >  0)
  16.                  System.arraycopy(elementData, index+ 1, elementData, index,
  17.                                   numMoved);
  18.              elementData[--size] =  null;  // clear to let GC do its work
  19.               return oldValue;
  20.          }

       从代码中不难看出,首先check是否数组越界,接下来根据index找到元素,然后将index+1到size-1位置的元素向前挪动一个位置,并返回要删除的元素。

         根据index获取元素:        

  1.            /**
  2.            * Returns the element at the specified position in this list.
  3.            *
  4.            *  @param  index index of the element to return
  5.            *  @return the element at the specified position in this list
  6.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  7.            */
  8.            public E  get ( int index) {
  9.              rangeCheck(index);
  10.               return elementData(index);
  11.          }

       从代码中不难看出,首先check数组越界问题,然后直接按照index从数组中获取元素。

         从以上三个方法的代码中不难看出,由于按index插入、删除数据涉及挪动index+1到size-1位置的全部数据,因此不适宜频繁随机写入、删除的场景。但由于其内部采用数组进行元素存储,因此比较适宜按index获取数据的场景。    

LinkedList

     LinkedList是双向链表,即同时保有前驱节点和后驱节点,支持正向遍历和反向遍历。                      

主要属性

  1.       private  static   class  Node< E> {
  2.              E item;
  3.              Node<E> next;
  4.              Node<E> prev;
  5.              Node(Node<E> prev, E element, Node<E> next) {
  6.                   this.item = element;
  7.                   this.next = next;
  8.                   this.prev = prev;
  9.              }
  10.          }

       从中可以看出,item为节点中的元素值,prev和next分别是前向节点和后向节点的引用。                      

构造函数

     默认构造函数和以集合为入参的构造函数。其中以集合为入参的构造函数如下:        

  1.            /**
  2.            * Constructs a list containing the elements of the specified
  3.            * collection, in the order they are returned by the collection's
  4.            * iterator.
  5.            *
  6.            *  @param  c the collection whose elements are to be placed into this list
  7.            *  @throws NullPointerException if the specified collection is null
  8.            */
  9.            public  LinkedList (Collection<? extends E> c) {
  10.               this();
  11.              addAll(c);
  12.          }
  13.            /**
  14.            * Appends all of the elements in the specified collection to the end of
  15.            * this list, in the order that they are returned by the specified
  16.            * collection's iterator.  The behavior of this operation is undefined if
  17.            * the specified collection is modified while the operation is in
  18.            * progress.  (Note that this will occur if the specified collection is
  19.            * this list, and it's nonempty.)
  20.            *
  21.            *  @param c collection containing elements to be added to this list
  22.            *  @return { @code true} if this list changed as a result of the call
  23.            *  @throws NullPointerException if the specified collection is null
  24.            */
  25.            public  boolean  addAll (Collection<? extends E> c) {
  26.               return addAll(size, c);
  27.          }
  28.         /**
  29.            * Inserts all of the elements in the specified collection into this
  30.            * list, starting at the specified position.  Shifts the element
  31.            * currently at that position (if any) and any subsequent elements to
  32.            * the right (increases their indices).  The new elements will appear
  33.            * in the list in the order that they are returned by the
  34.            * specified collection's iterator.
  35.            *
  36.            *  @param index index at which to insert the first element
  37.            *              from the specified collection
  38.            *  @param c collection containing elements to be added to this list
  39.            *  @return { @code true} if this list changed as a result of the call
  40.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  41.            *  @throws NullPointerException if the specified collection is null
  42.            */
  43.            public  boolean  addAll ( int index, Collection<? extends E> c) {
  44.              checkPositionIndex(index);
  45.              Object[] a = c.toArray();
  46.               int numNew = a.length;
  47.               if (numNew ==  0)
  48.                   return  false;
  49.              Node<E> pred, succ;
  50.               if (index == size) {
  51.                  succ =  null;
  52.                  pred = last;
  53.              }  else {
  54.                  succ = node(index);
  55.                  pred = succ.prev;
  56.              }
  57.               for (Object o : a) {
  58.                   @SuppressWarnings( "unchecked") E e = (E) o;
  59.                  Node<E> newNode =  new Node<>(pred, e,  null);
  60.                   if (pred ==  null)
  61.                      first = newNode;
  62.                   else
  63.                      pred.next = newNode;
  64.                  pred = newNode;
  65.              }
  66.               if (succ ==  null) {
  67.                  last = pred;
  68.              }  else {
  69.                  pred.next = succ;
  70.                  succ.prev = pred;
  71.              }
  72.              size += numNew;
  73.              modCount++;
  74.               return  true;
  75.          }

       可见,以给定集合构造LinkedList的步骤为:遍历给定的集合,将第一个元素作为LinkedList的first节点,然后之后的每一个元素负责将上一个节点的后继节点置为自身,最后一个元素作为LinkedList的last节点。                      

根据index添加、删除、修改、获取元素

     先看根据index添加元素。

         首先check index是否越界,接下来判断index是否为最后一个节点。

         如果是最后一个节点,则根据传入的元素值创建新节点,将last节点的后继节点设置为新节点,将新节点的前置节点设置为原last节点,将新节点设置为LinkedList的last节点,LinkedList的size加1;

         如果不是最后一个节点,则根据index查找到节点,根据传入的元素值创建新节点,将按index查找到的节点的前置节点作为新节点的前置节点,将新节点作为按index查找到的节点的前置节点,将按index查找到的节点的前置节点的后继节点设置为新节点,完成整个插入过程。        

  1.          /**
  2.            * Inserts the specified element at the specified position in this list.
  3.            * Shifts the element currently at that position (if any) and any
  4.            * subsequent elements to the right (adds one to their indices).
  5.            *
  6.            *  @param index index at which the specified element is to be inserted
  7.            *  @param element element to be inserted
  8.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  9.            */
  10.            public  void  add ( int index, E element) {
  11.              checkPositionIndex(index);
  12.               if (index == size)
  13.                  linkLast(element);
  14.               else
  15.                  linkBefore(element, node(index));
  16.          }
  17.            /**
  18.            * Inserts element e before non-null Node succ.
  19.            */
  20.            void  linkBefore (E e, Node<E> succ) {
  21.               // assert succ != null;
  22.               final Node<E> pred = succ.prev;
  23.               final Node<E> newNode =  new Node<>(pred, e, succ);
  24.              succ.prev = newNode;
  25.               if (pred ==  null)
  26.                  first = newNode;
  27.               else
  28.                  pred.next = newNode;
  29.              size++;
  30.              modCount++;
  31.          }
  32.            /**
  33.            * Returns the (non-null) Node at the specified element index.
  34.            */
  35.           Node<E>  node ( int index) {
  36.               // assert isElementIndex(index);
  37.               if (index < (size >>  1)) {
  38.                  Node<E> x = first;
  39.                   for ( int i =  0; i < index; i++)
  40.                      x = x.next;
  41.                   return x;
  42.              }  else {
  43.                  Node<E> x = last;
  44.                   for ( int i = size -  1; i > index; i--)
  45.                      x = x.prev;
  46.                   return x;
  47.              }
  48.          }

       再看根据index删除元素。从中不难看出,首先检查index是否越界,之后按index获取到节点,并进一步获取到其前置节点(prev)和后继节点(succ)。如果prev为null(即要删除的节点为头节点),则将succ变为头节点;反之,则将succ的前置节点设置为prev,将要删除节点的前置节点设置为null,将前向链接断开。如果succ为null,则将prev设置为尾节点;反之,则将   prev的后继节点设置为succ,将要删除节点的后继节点设置为null,将后继链接断开。最后将节点的value设置为null,size减1,完成全部删除工作。        

  1.            /**
  2.            * Removes the element at the specified position in this list.  Shifts any
  3.            * subsequent elements to the left (subtracts one from their indices).
  4.            * Returns the element that was removed from the list.
  5.            *
  6.            *  @param index the index of the element to be removed
  7.            *  @return the element previously at the specified position
  8.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  9.            */
  10.            public E  remove ( int index) {
  11.              checkElementIndex(index);
  12.               return unlink(node(index));
  13.          }
  14.         /**
  15.            * Unlinks non-null node x.
  16.            */
  17.           E  unlink (Node<E> x) {
  18.               // assert x != null;
  19.               final E element = x.item;
  20.               final Node<E> next = x.next;
  21.               final Node<E> prev = x.prev;
  22.               if (prev ==  null) {
  23.                  first = next;
  24.              }  else {
  25.                  prev.next = next;
  26.                  x.prev =  null;
  27.              }
  28.               if (next ==  null) {
  29.                  last = prev;
  30.              }  else {
  31.                  next.prev = prev;
  32.                  x.next =  null;
  33.              }
  34.              x.item =  null;
  35.              size--;
  36.              modCount++;
  37.               return element;
  38.          }

       再看根据index修改元素。操作过程为,首先检查index是否越界,接下来根据index定位节点,最后将节点的值变更。        

  1.            /**
  2.            * Replaces the element at the specified position in this list with the
  3.            * specified element.
  4.            *
  5.            *  @param index index of the element to replace
  6.            *  @param element element to be stored at the specified position
  7.            *  @return the element previously at the specified position
  8.            *  @throws IndexOutOfBoundsException { @inheritDoc}
  9.            */
  10.            public E  set ( int index, E element) {
  11.              checkElementIndex(index);
  12.              Node<E> x = node(index);
  13.              E oldVal = x.item;
  14.              x.item = element;
  15.               return oldVal;
  16.          }

       最后看根据index获取元素。其实上文中已经进行过介绍了,首先将index右移1位(其实就是除以2),如果index在前半段,那就从first节点开始往后查找,反之就从last节点开始往前查找。这样可以保证最多查找一半的元素就可以找到。        

  1.            /**
  2.            * Returns the (non-null) Node at the specified element index.
  3.            */
  4.           Node<E>  node ( int index) {
  5.               // assert isElementIndex(index);
  6.               if (index < (size >>  1)) {
  7.                  Node<E> x = first;
  8.                   for ( int i =  0; i < index; i++)
  9.                      x = x.next;
  10.                   return x;
  11.              }  else {
  12.                  Node<E> x = last;
  13.                   for ( int i = size -  1; i > index; i--)
  14.                      x = x.prev;
  15.                   return x;
  16.              }
  17.          }

       从上述的按index新增、删除、获取、修改等方法不难看出,由于LinkedList本质上是双向链表的实现,因此在根据index获取元素的时候,需要从头节点或尾节点遍历链表中的元素,找到位置为index的节点(最多遍历size/2的节点)。而在按index新增、删除元素的时候,仅需找到对应index的节点,然后插入新的节点或将该节点断开与前置节点与后继节点的链接即可。

         相比于以数组为存储形式的ArrayList,LinkedList不适用于频繁按index读取元素的场景(因为其不是连续存储,需要做链表遍历),但适用于按index插入、删除元素的场景(因为主要开销在链表遍历,一旦找到index位置的节点,就可以灵活地通过插入节点或将节点解除双向链接的方式完成;相比之下,ArrayList需要将index之后的元素进行挪动)。    

Map

     我们在此主要介绍Map接口的两个实现类,线程不安全的HashMap和线程安全的ConcurrentHashMap。    

HashMap

     首先介绍线程不安全的HashMap。这里推荐一篇图文并茂的文章:https://juejin.im/post/5aa5d8d26fb9a028d2079264。    

重要属性

  1.         /**
  2.            * The table, initialized on first use, and resized as
  3.            * necessary. When allocated, length is always a power of two.
  4.            * (We also tolerate length zero in some operations to allow
  5.            * bootstrapping mechanics that are currently not needed.)
  6.            */
  7.           transient Node<K,V>[] table;
  8.            /**
  9.            * The number of key-value mappings contained in this map.
  10.            */
  11.           transient  int size;
  12.            /**
  13.            * The next size value at which to resize (capacity * load factor).
  14.            *
  15.            *  @serial
  16.            */
  17.           // (The javadoc description is true upon serialization.
  18.           // Additionally, if the table array has not been allocated, this
  19.           // field holds the initial array capacity, or zero signifying
  20.           // DEFAULT_INITIAL_CAPACITY.)
  21.           int threshold;

       table属性即为分桶。

         size属性表示HashMap中存储的Key-Value对儿的个数。

         threshold为判断是否需要进行扩容的门限值。    

构造函数

  1.        /**
  2.            * Constructs an empty <tt>HashMap</tt> with the specified initial
  3.            * capacity and load factor.
  4.            *
  5.            *  @param  initialCapacity the initial capacity
  6.            *  @param  loadFactor      the load factor
  7.            *  @throws IllegalArgumentException if the initial capacity is negative
  8.            *         or the load factor is nonpositive
  9.            */
  10.            public  HashMap ( int initialCapacity,  float loadFactor) {
  11.               if (initialCapacity <  0)
  12.                   throw  new IllegalArgumentException( "Illegal initial capacity: " +
  13.                                                     initialCapacity);
  14.               if (initialCapacity > MAXIMUM_CAPACITY)
  15.                  initialCapacity = MAXIMUM_CAPACITY;
  16.               if (loadFactor <=  0 || Float.isNaN(loadFactor))
  17.                   throw  new IllegalArgumentException( "Illegal load factor: " +
  18.                                                     loadFactor);
  19.               this.loadFactor = loadFactor;
  20.               this.threshold = tableSizeFor(initialCapacity);
  21.          }
  22.            /**
  23.            * Constructs an empty <tt>HashMap</tt> with the specified initial
  24.            * capacity and the default load factor (0.75).
  25.            *
  26.            *  @param  initialCapacity the initial capacity.
  27.            *  @throws IllegalArgumentException if the initial capacity is negative.
  28.            */
  29.            public  HashMap ( int initialCapacity) {
  30.               this(initialCapacity, DEFAULT_LOAD_FACTOR);
  31.          }
  32.            /**
  33.            * Constructs an empty <tt>HashMap</tt> with the default initial capacity
  34.            * (16) and the default load factor (0.75).
  35.            */
  36.            public  HashMap () {
  37.               this.loadFactor = DEFAULT_LOAD_FACTOR;  // all other fields defaulted
  38.          }
  39.            /**
  40.            * Constructs a new <tt>HashMap</tt> with the same mappings as the
  41.            * specified <tt>Map</tt>.  The <tt>HashMap</tt> is created with
  42.            * default load factor (0.75) and an initial capacity sufficient to
  43.            * hold the mappings in the specified <tt>Map</tt>.
  44.            *
  45.            *  @param   m the map whose mappings are to be placed in this map
  46.            *  @throws  NullPointerException if the specified map is null
  47.            */
  48.            public  HashMap (Map<? extends K, ? extends V> m) {
  49.               this.loadFactor = DEFAULT_LOAD_FACTOR;
  50.              putMapEntries(m,  false);
  51.          }
  52.            /**
  53.            * Implements Map.putAll and Map constructor
  54.            *
  55.            *  @param m the map
  56.            *  @param evict false when initially constructing this map, else
  57.            * true (relayed to method afterNodeInsertion).
  58.            */
  59.            final  void  putMapEntries (Map<? extends K, ? extends V> m,  boolean evict) {
  60.               int s = m.size();
  61.               if (s >  0) {
  62.                   if (table ==  null) {  // pre-size
  63.                       float ft = (( float)s / loadFactor) +  1.0F;
  64.                       int t = ((ft < ( float)MAXIMUM_CAPACITY) ?
  65.                               ( int)ft : MAXIMUM_CAPACITY);
  66.                       if (t > threshold)
  67.                          threshold = tableSizeFor(t);
  68.                  }
  69.                   else  if (s > threshold)
  70.                      resize();
  71.                   for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) {
  72.                      K key = e.getKey();
  73.                      V value = e.getValue();
  74.                      putVal(hash(key), key, value,  false, evict);
  75.                  }
  76.              }
  77.          }

       其中最为重要的就是根据传入的initialCapacity计算threshold的方法,如下所示:        

  1.          /**
  2.            * Returns a power of two size for the given target capacity.
  3.            */
  4.            static  final  int  tableSizeFor ( int cap) {
  5.               int n = cap -  1;
  6.              n |= n >>>  1;
  7.              n |= n >>>  2;
  8.              n |= n >>>  4;
  9.              n |= n >>>  8;
  10.              n |= n >>>  16;
  11.               return (n <  0) ?  1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n +  1;
  12.          }

       其功能在于计算得到大于等于initialCapacity的最小的2的正整数幂。    

添加KV

     添加KV方法算是HashMap中最为重要的几个方法之一了。

         先上源码:        

  1.            /**
  2.            * Associates the specified value with the specified key in this map.
  3.            * If the map previously contained a mapping for the key, the old
  4.            * value is replaced.
  5.            *
  6.            *  @param key key with which the specified value is to be associated
  7.            *  @param value value to be associated with the specified key
  8.            *  @return the previous value associated with <tt>key</tt>, or
  9.            *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
  10.            *         (A <tt>null</tt> return can also indicate that the map
  11.            *         previously associated <tt>null</tt> with <tt>key</tt>.)
  12.            */
  13.            public V  put (K key, V value) {
  14.               return putVal(hash(key), key, value,  false,  true);
  15.          }
  16.            static  final  int  hash (Object key) {
  17.               int h;
  18.               return (key ==  null) ?  0 : (h = key.hashCode()) ^ (h >>>  16);
  19.          }
  20.         final V  putVal ( int hash, K key, V value,  boolean onlyIfAbsent,
  21.                          boolean evict) {
  22.              Node<K,V>[] tab; Node<K,V> p;  int n, i;
  23.               if ((tab = table) ==  null || (n = tab.length) ==  0)
  24.                  n = (tab = resize()).length;
  25.               if ((p = tab[i = (n -  1) & hash]) ==  null)
  26.                  tab[i] = newNode(hash, key, value,  null);
  27.               else {
  28.                  Node<K,V> e; K k;
  29.                   if (p.hash == hash &&
  30.                      ((k = p.key) == key || (key !=  null && key.equals(k))))
  31.                      e = p;
  32.                   else  if (p  instanceof TreeNode)
  33.                      e = ((TreeNode<K,V>)p).putTreeVal( this, tab, hash, key, value);
  34.                   else {
  35.                       for ( int binCount =  0; ; ++binCount) {
  36.                           if ((e = p.next) ==  null) {
  37.                              p.next = newNode(hash, key, value,  null);
  38.                               if (binCount >= TREEIFY_THRESHOLD -  1)  // -1 for 1st
  39.                                  treeifyBin(tab, hash);
  40.                               break;
  41.                          }
  42.                           if (e.hash == hash &&
  43.                              ((k = e.key) == key || (key !=  null && key.equals(k))))
  44.                               break;
  45.                          p = e;
  46.                      }
  47.                  }
  48.                   if (e !=  null) {  // existing mapping for key
  49.                      V oldValue = e.value;
  50.                       if (!onlyIfAbsent || oldValue ==  null)
  51.                          e.value = value;
  52.                      afterNodeAccess(e);
  53.                       return oldValue;
  54.                  }
  55.              }
  56.              ++modCount;
  57.               if (++size > threshold)
  58.                  resize();
  59.              afterNodeInsertion(evict);
  60.               return  null;
  61.          }

       个人感觉该方法中的信息量还是比较大的,该方法在1.8版本中,在处理落入同一个分桶的数据时,较历史版本有所更新。

         之前版本中,对于该方法的处理是这样的流程:                      
  1. 根据给出的key,计算hash值(key的hashCode方法),从而定位到分桶;
  2. 检查定位到的分桶中是否已经存在了数据。如果没有,则直接将数据放入分桶中;反之,则将数据加入分桶的链表中。
以上操作存在一个问题,那就是当分桶中数据比较多的时候,get方法需要在根据key的hash值定位到具体分桶后,还需要进行链表遍历才能找到需要获取到的value。假设链表长度为n,则时间复杂度为O(n),效率不够理想。

         有什么办法进行改进呢?对数据结构有所了解的同学们立刻就能反应到,相对于链表的遍历,二叉树的遍历往往能够减小时间复杂度。因此在JDK8中对此进行了功能增强,变为如下流程:    
  1. 据给出的key,计算hash值(key的hashCode方法),从而定位到分桶,此步骤与改版前一致;
  2. 检查分桶中是否有数据,如果没有数据则直接将数据放入分桶中;反之,更精细化地进行处理。对于分桶中不太多数据的场景(个数小于TREEIFY_THRESHOLD-1)采用链表的方式,将新节点放到链表的尾部;对于分桶中较多数据的场景(个数大于等于TREEIFY_THRESHOLD-1),采用红黑树的方式,将节点进行存储。这样一来,既减轻了数据结构的复杂程度(红黑树较链表要复杂一些),又在链表较长的情况下,有效地减少了遍历节点的时间复杂度。个人觉得,这算是JDK8中,对于解决此问题的很精巧的一点。
下面我们仔细地看一下这个方法的代码。

         首先,需要先根据key找到对应的分桶,所使用的方法是key.hashCode()右移16位,再与自身按位异或运算得到的hash值,再与分桶总数-1进行按位与操作。初看这个方法的时候,你一定很疑惑,取了hashCode之后为什么还要如此复杂地右移16位,再与自身按位异或才能获取到hash值。原因在于,hashCode方法返回的hash值并不够完全随机,为了更好地使得不同的key均匀地散落在不同的分桶中(换句话说,为了不同key的hash值分布得更加均匀),在原有的调用hashCode方法的基础上,又做了一次运算,将结果进一步地随机化。之后逻辑上需要将计算得来的h值,按照分桶总数取模,这样才能尽可能地保证均匀地分配到不同的分桶中。但是,计算机取模运算的效率不高,所以采用了与分桶总数-1进行按位与操作,也能达到同样的效果。

         接下来,根据分桶中已有的数据的情况来判断如何将输入的Key-Value存储到分桶中。如果分桶中没有数据,那么就将输入的Key-Value转化成存储节点Node,存储到分桶中;如果分桶中有数据,且已采用红黑树进行存储了,则将该存储节点插入到红黑树中,以优化后续查找性能;如果分桶中的数据依然是使用链表进行存储,则存储到链表的尾部,之后判断是否达到树化条件(链表中存储的数据个数大于等于TREEIFY_THRESHOLD-1),达到的话就将链表转成红黑树存储。具体的插入红黑树的代码就不再这里赘述了,感兴趣的同学可在参照红黑树的介绍文章:https://baike.baidu.com/item/%E7%BA%A2%E9%BB%91%E6%A0%91。

         最后,在插入节点之后,判断是否要进行扩容(resize),扩容的条件是加入新节点后,存储的Key-Value的个数大于threshold(threshold的赋值参见构造函数中,为大于等于initialCapacity的最小的2的正整数幂)。扩容的具体操作步骤如下:        

  1.         /**
  2.            * Initializes or doubles table size.  If null, allocates in
  3.            * accord with initial capacity target held in field threshold.
  4.            * Otherwise, because we are using power-of-two expansion, the
  5.            * elements from each bin must either stay at same index, or move
  6.            * with a power of two offset in the new table.
  7.            *
  8.            *  @return the table
  9.            */
  10.           final Node<K,V>[] resize() {
  11.              Node<K,V>[] oldTab = table;
  12.               int oldCap = (oldTab ==  null) ?  0 : oldTab.length;
  13.               int oldThr = threshold;
  14.               int newCap, newThr =  0;
  15.               if (oldCap >  0) {
  16.                   if (oldCap >= MAXIMUM_CAPACITY) {
  17.                      threshold = Integer.MAX_VALUE;
  18.                       return oldTab;
  19.                  }
  20.                   else  if ((newCap = oldCap <<  1) < MAXIMUM_CAPACITY &&
  21.                           oldCap >= DEFAULT_INITIAL_CAPACITY)
  22.                      newThr = oldThr <<  1;  // double threshold
  23.              }
  24.               else  if (oldThr >  0)  // initial capacity was placed in threshold
  25.                  newCap = oldThr;
  26.               else {                // zero initial threshold signifies using defaults
  27.                  newCap = DEFAULT_INITIAL_CAPACITY;
  28.                  newThr = ( int)(DEFAULT_LOAD_FACTOR * DEFAULT_INITIAL_CAPACITY);
  29.              }
  30.               if (newThr ==  0) {
  31.                   float ft = ( float)newCap * loadFactor;
  32.                  newThr = (newCap < MAXIMUM_CAPACITY && ft < ( float)MAXIMUM_CAPACITY ?
  33.                            ( int)ft : Integer.MAX_VALUE);
  34.              }
  35.              threshold = newThr;
  36.               @SuppressWarnings({ "rawtypes", "unchecked"})
  37.                  Node<K,V>[] newTab = (Node<K,V>[]) new Node[newCap];
  38.              table = newTab;
  39.               if (oldTab !=  null) {
  40.                   for ( int j =  0; j < oldCap; ++j) {
  41.                      Node<K,V> e;
  42.                       if ((e = oldTab[j]) !=  null) {
  43.                          oldTab[j] =  null;
  44.                           if (e.next ==  null)
  45.                              newTab[e.hash & (newCap -  1)] = e;
  46.                           else  if (e  instanceof TreeNode)
  47.                              ((TreeNode<K,V>)e).split( this, newTab, j, oldCap);
  48.                           else {  // preserve order
  49.                              Node<K,V> loHead =  null, loTail =  null;
  50.                              Node<K,V> hiHead =  null, hiTail =  null;
  51.                              Node<K,V> next;
  52.                               do {
  53.                                  next = e.next;
  54.                                   if ((e.hash & oldCap) ==  0) {
  55.                                       if (loTail ==  null)
  56.                                          loHead = e;
  57.                                       else
  58.                                          loTail.next = e;
  59.                                      loTail = e;
  60.                                  }
  61.                                   else {
  62.                                       if (hiTail ==  null)
  63.                                          hiHead = e;
  64.                                       else
  65.                                          hiTail.next = e;
  66.                                      hiTail = e;
  67.                                  }
  68.                              }  while ((e = next) !=  null);
  69.                               if (loTail !=  null) {
  70.                                  loTail.next =  null;
  71.                                  newTab[j] = loHead;
  72.                              }
  73.                               if (hiTail !=  null) {
  74.                                  hiTail.next =  null;
  75.                                  newTab[j + oldCap] = hiHead;
  76.                              }
  77.                          }
  78.                      }
  79.                  }
  80.              }
  81.               return newTab;
  82.          }

       首先计算得到扩充后的threshold和capacity,然后将扩容前的各分桶中的数据按照新分桶的定位计算方法,定位到新分桶中,然后依次进行迁移。注意代码中涉及到的HashMap中的table属性在多线程操作时是临界资源,因此HashMap不是线程安全的,需要在代码中做线程安全保护。此外,我们观察到HashMap的resize方法,需要进行新分桶的threshold/capacity重新计算,旧数据按照新分桶进行重新定位,旧分桶中的数据按新规则向新分桶中迁移,这里边的开销还是比较大的,因此比较建议在创建HashMap实例的时候,尽可能地根据业务需求对HashMap的capacity进行一个预估,避免HashMap在程序运行过程中频繁进行扩容计算,提升性能。                      

根据Key获取Value

     在了解了Key-Value的插入方法之后,再了解如何根据Key获取Value就会简单许多。get方法代码如下:        

  1.            /**
  2.            * Returns the value to which the specified key is mapped,
  3.            * or { @code null} if this map contains no mapping for the key.
  4.            *
  5.            * <p>More formally, if this map contains a mapping from a key
  6.            * { @code k} to a value { @code v} such that { @code (key==null ? k==null :
  7.            * key.equals(k))}, then this method returns { @code v}; otherwise
  8.            * it returns { @code null}.  (There can be at most one such mapping.)
  9.            *
  10.            * <p>A return value of { @code null} does not <i>necessarily</i>
  11.            * indicate that the map contains no mapping for the key; it's also
  12.            * possible that the map explicitly maps the key to { @code null}.
  13.            * The { @link #containsKey containsKey} operation may be used to
  14.            * distinguish these two cases.
  15.            *
  16.            *  @see #put(Object, Object)
  17.            */
  18.            public V  get (Object key) {
  19.              Node<K,V> e;
  20.               return (e = getNode(hash(key), key)) ==  null ?  null : e.value;
  21.          }
  22.            /**
  23.            * Implements Map.get and related methods
  24.            *
  25.            *  @param hash hash for key
  26.            *  @param key the key
  27.            *  @return the node, or null if none
  28.            */
  29.            final Node<K,V>  getNode ( int hash, Object key) {
  30.              Node<K,V>[] tab; Node<K,V> first, e;  int n; K k;
  31.               if ((tab = table) !=  null && (n = tab.length) >  0 &&
  32.                  (first = tab[(n -  1) & hash]) !=  null) {
  33.                   if (first.hash == hash &&  // always check first node
  34.                      ((k = first.key) == key || (key !=  null && key.equals(k))))
  35.                       return first;
  36.                   if ((e = first.next) !=  null) {
  37.                       if (first  instanceof TreeNode)
  38.                           return ((TreeNode<K,V>)first).getTreeNode(hash, key);
  39.                       do {
  40.                           if (e.hash == hash &&
  41.                              ((k = e.key) == key || (key !=  null && key.equals(k))))
  42.                               return e;
  43.                      }  while ((e = e.next) !=  null);
  44.                  }
  45.              }
  46.               return  null;
  47.          }

       整体步骤分为以下几步:    
  1. 按照put方法中描述的规则,根据key定位到分桶;
  2. 将key与分桶中第一个节点的key做equals比较,如果相等则返回;不相等则考虑与后续节点进行比对。分两种情况,如果分桶中存储的是红黑树,则做树的遍历查找;如果存储的是链表,则做链表的遍历查找。如果遍历结束依然没有找到,则返回null。

根据Key删除

     remove方法的操作步骤如下:        

  1.         /**
  2.            * Removes the mapping for the specified key from this map if present.
  3.            *
  4.            *  @param  key key whose mapping is to be removed from the map
  5.            *  @return the previous value associated with <tt>key</tt>, or
  6.            *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
  7.            *         (A <tt>null</tt> return can also indicate that the map
  8.            *         previously associated <tt>null</tt> with <tt>key</tt>.)
  9.            */
  10.            public V  remove (Object key) {
  11.              Node<K,V> e;
  12.               return (e = removeNode(hash(key), key,  null,  false,  true)) ==  null ?
  13.                   null : e.value;
  14.          }
  15.            /**
  16.            * Implements Map.remove and related methods
  17.            *
  18.            *  @param hash hash for key
  19.            *  @param key the key
  20.            *  @param value the value to match if matchValue, else ignored
  21.            *  @param matchValue if true only remove if value is equal
  22.            *  @param movable if false do not move other nodes while removing
  23.            *  @return the node, or null if none
  24.            */
  25.            final Node<K,V>  removeNode ( int hash, Object key, Object value,
  26.                                      boolean matchValue,  boolean movable) {
  27.              Node<K,V>[] tab; Node<K,V> p;  int n, index;
  28.               if ((tab = table) !=  null && (n = tab.length) >  0 &&
  29.                  (p = tab[index = (n -  1) & hash]) !=  null) {
  30.                  Node<K,V> node =  null, e; K k; V v;
  31.                   if (p.hash == hash &&
  32.                      ((k = p.key) == key || (key !=  null && key.equals(k))))
  33.                      node = p;
  34.                   else  if ((e = p.next) !=  null) {
  35.                       if (p  instanceof TreeNode)
  36.                          node = ((TreeNode<K,V>)p).getTreeNode(hash, key);
  37.                       else {
  38.                           do {
  39.                               if (e.hash == hash &&
  40.                                  ((k = e.key) == key ||
  41.                                   (key !=  null && key.equals(k)))) {
  42.                                  node = e;
  43.                                   break;
  44.                              }
  45.                              p = e;
  46.                          }  while ((e = e.next) !=  null);
  47.                      }
  48.                  }
  49.                   if (node !=  null && (!matchValue || (v = node.value) == value ||
  50.                                       (value !=  null && value.equals(v)))) {
  51.                       if (node  instanceof TreeNode)
  52.                          ((TreeNode<K,V>)node).removeTreeNode( this, tab, movable);
  53.                       else  if (node == p)
  54.                          tab[index] = node.next;
  55.                       else
  56.                          p.next = node.next;
  57.                      ++modCount;
  58.                      --size;
  59.                      afterNodeRemoval(node);
  60.                       return node;
  61.                  }
  62.              }
  63.               return  null;
  64.          }

  1. 根据key定位到分桶;
  2. 从分桶中找到要删除的节点;
  3. 删除节点,并将size-1。

ConcurrentHashMap

     ConcurrentHashMap是线程安全的HashMap,在JDK8中,ConcurrentHashMap为进一步优化多线程下的并发性能,不再采用分段锁对分桶进行保护,而是采用CAS操作(Compare And Set)。这个改变在思想上很像是乐观锁与悲观锁。

         在JDK8之前,ConcurrentHashMap采用分段锁的方式来保证线程安全性,相对于CAS操作,量级更重一些,因为需要做加锁、解锁操作。这很类似于悲观锁的思想,即假设多线程并发操作临界资源的几率比较大,因此采用加锁的方式来应对。

         JDK8中,采用了轻量级的CAS操作来获取及向分桶中写入元素(当分桶中没有元素存储时),采用类似LongAdder的方式计算ConcurrentHashMap的size,使得多线程操作时,采用更轻量级的方式加以应对。CAS很类似于乐观锁的思想,而LongAdder是将多线程的+1操作随机地定位到不同分桶中来避免写入时的冲突,在计算size时,通过将各分桶中的数值进行叠加从而得到总的size值,从而很好地解决了多线程+1写操作的冲突和加锁等待问题。    

构造函数

     与HashMap相类似,ConcurrentHashMap的构造函数也分为以下几个:    
  1. 默认构造函数:空实现;
  2. 给定initialCapacity的构造函数;
  3. 拷贝构造函数。
这里我们关注以下给定initialCapacity的构造函数,之所以关注这个构造函数,是因为HashMap与ConcurrentHashMap的reSize扩容过程都属于开销比较大的操作,所以期望使用者在使用的时候尽可能地根据业务需求对size有一个大致的预估,并使用该构造函数对Map进行构造,以避免后续不断地扩容操作,给性能带来不利的影响。

         我们都还记得上文中提到的HashMap的size计算,其值等于大于等于initialCapacity的最小的2的正整数幂。而ConcurrentHashMap的该构造函数源码如下:        

  1.          /**
  2.            * Creates a new, empty map with an initial table size
  3.            * accommodating the specified number of elements without the need
  4.            * to dynamically resize.
  5.            *
  6.            *  @param initialCapacity The implementation performs internal
  7.            * sizing to accommodate this many elements.
  8.            *  @throws IllegalArgumentException if the initial capacity of
  9.            * elements is negative
  10.            */
  11.            public  ConcurrentHashMap ( int initialCapacity) {
  12.               if (initialCapacity <  0)
  13.                   throw  new IllegalArgumentException();
  14.               int cap = ((initialCapacity >= (MAXIMUM_CAPACITY >>>  1)) ?
  15.                         MAXIMUM_CAPACITY :
  16.                         tableSizeFor(initialCapacity + (initialCapacity >>>  1) +  1));
  17.               this.sizeCtl = cap;
  18.          }

       从中不难看出,ConcurrentHashMap的sizeCtl值大于等于1.5倍的initialCapacity+1的最小2的正整数幂。

         而拷贝构造函数的思路则是遍历入参中的Map,然后依次将其put到本次创建的ConcurrentHashMap中,put方法的操作过程我会在下边加以详细介绍,所以此处不再赘述。    

添加KV

     put方法与HashMap的put方法在基本思路上是一致的,主要分以下步骤:                      
  1. 对传入的key计算hashCode,然后计算获取到index,即指向哪个分桶;
  2. 访问到指定的分桶,如果分桶中此时没有节点,则将KV做插入处理;如果分桶中已经有节点了,则判断是树节点还是链表节点,然后根据树或是链表进行遍历。如果该Key已经存储到了Map中了,则将新值写入,旧值返回;反之,则创建新节点,存储到树的合适位置,或者是链表的尾节点(当然还会根据链表中存储的节点数来判断是否应该进行树化处理);
  3. 将size自增1,并判断是否需要进行reSize扩容操作,是则进行扩容,即生成新的分桶,将旧有分桶中的节点根据新的规则拷贝并创建到新的分桶中。
只不过ConcurrentHashMap为了保证其是线程安全的,因此采用了一系列的手段来保证这一点。        

  1.         /**
  2.            * Maps the specified key to the specified value in this table.
  3.            * Neither the key nor the value can be null.
  4.            *
  5.            * <p>The value can be retrieved by calling the { @code get} method
  6.            * with a key that is equal to the original key.
  7.            *
  8.            *  @param key key with which the specified value is to be associated
  9.            *  @param value value to be associated with the specified key
  10.            *  @return the previous value associated with { @code key}, or
  11.            *         { @code null} if there was no mapping for { @code key}
  12.            *  @throws NullPointerException if the specified key or value is null
  13.            */
  14.            public V  put (K key, V value) {
  15.               return putVal(key, value,  false);
  16.          }
  17.           /** Implementation for put and putIfAbsent */
  18.            final V  putVal (K key, V value,  boolean onlyIfAbsent) {
  19.               if (key ==  null || value ==  null)  throw  new NullPointerException();
  20.               int hash = spread(key.hashCode());
  21.               int binCount =  0;
  22.               for (Node<K,V>[] tab = table;;) {
  23.                  Node<K,V> f;  int n, i, fh;
  24.                   if (tab ==  null || (n = tab.length) ==  0)
  25.                      tab = initTable();
  26.                   else  if ((f = tabAt(tab, i = (n -  1) & hash)) ==  null) {
  27.                       if (casTabAt(tab, i,  null,
  28.                                    new Node<K,V>(hash, key, value,  null)))
  29.                           break;                    // no lock when adding to empty bin
  30.                  }
  31.                   else  if ((fh = f.hash) == MOVED)
  32.                      tab = helpTransfer(tab, f);
  33.                   else {
  34.                      V oldVal =  null;
  35.                       synchronized (f) {
  36.                           if (tabAt(tab, i) == f) {
  37.                               if (fh >=  0) {
  38.                                  binCount =  1;
  39.                                   for (Node<K,V> e = f;; ++binCount) {
  40.                                      K ek;
  41.                                       if (e.hash == hash &&
  42.                                          ((ek = e.key) == key ||
  43.                                           (ek !=  null && key.equals(ek)))) {
  44.                                          oldVal = e.val;
  45.                                           if (!onlyIfAbsent)
  46.                                              e.val = value;
  47.                                           break;
  48.                                      }
  49.                                      Node<K,V> pred = e;
  50.                                       if ((e = e.next) ==  null) {
  51.                                          pred.next =  new Node<K,V>(hash, key,
  52.                                                                    value,  null);
  53.                                           break;
  54.                                      }
  55.                                  }
  56.                              }
  57.                               else  if (f  instanceof TreeBin) {
  58.                                  Node<K,V> p;
  59.                                  binCount =  2;
  60.                                   if ((p = ((TreeBin<K,V>)f).putTreeVal(hash, key,
  61.                                                                 value)) !=  null) {
  62.                                      oldVal = p.val;
  63.                                       if (!onlyIfAbsent)
  64.                                          p.val = value;
  65.                                  }
  66.                              }
  67.                          }
  68.                      }
  69.                       if (binCount !=  0) {
  70.                           if (binCount >= TREEIFY_THRESHOLD)
  71.                              treeifyBin(tab, i);
  72.                           if (oldVal !=  null)
  73.                               return oldVal;
  74.                           break;
  75.                      }
  76.                  }
  77.              }
  78.              addCount( 1L, binCount);
  79.               return  null;
  80.          }

       关注其中在获取分桶中节点的tabAt方法,和向分桶中添加节点的casTabAt方法,二者在底层都使用到了sun.misc.Unsafe。关于Unsafe,可参考文章:https://blog.csdn.net/anla_/article/details/78631026  。简单说就是,Unsafe提供了硬件级别的原子操作。借助于Unsafe类,tabAt方法能够获取到分桶中的节点,casTabAt方法能够采用CAS的方式将新节点写入到分桶中,即如果分桶中如果当前存储的节点与刚才使用tabAt方法获取到的相同,则将新节点覆盖之前的节点;反之,则说明在当前线程设置之前,其他线程已经改变了分桶中的节点,因此本线程的设置操作失败。

         如果CAS操作失败了,则进入到下边的分支,首先check是否该节点在迁移中(迁移中的节点的hash值为-1,有可能是在reSize扩容中),如果不在迁移过程中,则采用synchronized关键字,对tabAt获取到的节点加锁,然后像上文中陈述的步骤2那样完成新KV的写入操作。

         最后一步则是将ConcurrentHashMap的size+1,并根据已存储的节点的个数判断是否要进行reSize扩容操作。为了满足线程安全性,并尽可能地提升size+1的性能,ConcurrentHashMap采用的是类似于LongAdder的方式来完成size+1这个操作的。可参考文章:https://www.cnblogs.com/ten951/p/6590596.html   。LongAdder的思想本质上就是将多线程操作同一个变量(将同一个size做+1操作),转变为多线程随机向一组cell做写入,通过将各cell中的value累加,即可得到总的值,虽然这个值可能不准。这样即可由多线程集中写,转变为多线程分散写,有效地减轻了多线程操作时的竞争。    

根据Key获取Value

     在了解了put方法之后,再去看get方法就会明晰很多。        
  1.            /**
  2.            * Returns the value to which the specified key is mapped,
  3.            * or { @code null} if this map contains no mapping for the key.
  4.            *
  5.            *



    [这个贴子最后由 flybird 在 2020-02-04 20:52:19 重新编辑]
  Java面向对象编程-->Java语言的基本语法和规范
  JavaWeb开发-->Servlet技术详解(Ⅱ)
  JSP与Hibernate开发-->Spring、JPA与Hibernate的整合
  Java网络编程-->通过JavaMail API收发邮件
  精通Spring-->Vue组件开发高级技术
  Vue3开发-->Vue组件开发高级技术
  10道Java编程基础练习题
  快速理解 函数式编程,响应式编程,链式编程
  NIO模式的IO多路复用底层原理
  面向对象的七大原则,你知道几个?
  Java泛型中的通配符 T,E,K,V,? 你了解吗
  使用策略模式优化代码实践,如何让项目快速起飞
  Redis安装、Redis基本数据类型、Jedis、Redis集群搭建
  java 中文繁简体转换工具 opencc4j
  Java设计模式:抽象工厂模式
  Java多线程volatile详解
  正则表达式基础入门
  Java设计模式:解释器模式
  Java入门实用代码:数组转集合
  Java入门实用代码:将文件内容复制到另一个文件
  Java入门实用代码:字符串替换
  更多...
 IPIP: 已设置保密
楼主      
该用户目前不在线 发货33 
  

威望: 0
级别: 侠客
魅力: 195
经验: 195
现金: 1152
发文章数: 19
注册时间: 0001-01-01
 消息  查看  搜索  好友  邮件  复制  引用


168won
168won福彩3D稳赚方法
168wonSG飞艇开奖直播
发文章时间 2022-09-13 11:31:05
 IPIP: 已设置保密 1 楼     
1页 1条记录 当前第1
发表一个新主题 开启一个新投票 回复文章


中文版权所有: JavaThinker技术网站 Copyright 2016-2026 沪ICP备16029593号-2
荟萃Java程序员智慧的结晶,分享交流Java前沿技术。  联系我们
如有技术文章涉及侵权,请与本站管理员联系。