1. /**
  2. * The number of times this list has been <i>structurally modified</i>.
  3. * Structural modifications are those that change the size of the
  4. * list, or otherwise perturb it in such a fashion that iterations in
  5. * progress may yield incorrect results.
  6. *
  7. * <p>This field is used by the iterator and list iterator implementation
  8. * returned by the {@code iterator} and {@code listIterator} methods.
  9. * If the value of this field changes unexpectedly, the iterator (or list
  10. * iterator) will throw a {@code ConcurrentModificationException} in
  11. * response to the {@code next}, {@code remove}, {@code previous},
  12. * {@code set} or {@code add} operations. This provides
  13. * <i>fail-fast</i> behavior, rather than non-deterministic behavior in
  14. * the face of concurrent modification during iteration.
  15. *
  16. * <p><b>Use of this field by subclasses is optional.</b> If a subclass
  17. * wishes to provide fail-fast iterators (and list iterators), then it
  18. * merely has to increment this field in its {@code add(int, E)} and
  19. * {@code remove(int)} methods (and any other methods that it overrides
  20. * that result in structural modifications to the list). A single call to
  21. * {@code add(int, E)} or {@code remove(int)} must add no more than
  22. * one to this field, or the iterators (and list iterators) will throw
  23. * bogus {@code ConcurrentModificationExceptions}. If an implementation
  24. * does not wish to provide fail-fast iterators, this field may be
  25. * ignored.
  26. */
  27. protected transient int modCount = 0;

迭代器要用到modCount属性

  1. /**
  2. * The array buffer into which the components of the vector are
  3. * stored. The capacity of the vector is the length of this array buffer,
  4. * and is at least large enough to contain all the vector's elements.
  5. *
  6. * <p>Any array elements following the last element in the Vector are null.
  7. *
  8. * @serial
  9. */
  10. protected Object[] elementData;

Vector的元素就存储在这个Object数组里,因而Vector的容量就是这个数组的长度,其值至少要大于Vector的要存储的元素的数量,该数组最后一个元素之后的元素都是null。

  1. /**
  2. * The number of valid components in this {@code Vector} object.
  3. * Components {@code elementData[0]} through
  4. * {@code elementData[elementCount-1]} are the actual items.
  5. *
  6. * @serial
  7. */
  8. protected int elementCount;

这个值代表Vector内有效数据的数量,而且起始元素的下标为0。

  1. /**
  2. * The amount by which the capacity of the vector is automatically
  3. * incremented when its size becomes greater than its capacity. If
  4. * the capacity increment is less than or equal to zero, the capacity
  5. * of the vector is doubled each time it needs to grow.
  6. *
  7. * @serial
  8. */
  9. protected int capacityIncrement;

有了这个值后,当Vector的大小超过了它的容量的时,Vector的容量才可以实现自动增长。当capacityIncrement小于等于0时,vector的容量就会在需要增长时直接翻倍。(该值可以在初始化时和初始容量一块指定,不指定时默认为0,初始容量默认为10)

  1. /**
  2. * Constructs a vector 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
  7. * vector
  8. * @throws NullPointerException if the specified collection is null
  9. * @since 1.2
  10. */
  11. public Vector(Collection<? extends E> c) {
  12. elementData = c.toArray();
  13. elementCount = elementData.length;
  14. // c.toArray might (incorrectly) not return Object[] (see 6260652)
  15. if (elementData.getClass() != Object[].class)
  16. elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
  17. }

也可以通过给定的集合来初始化一个Vector,通过该集合的迭代器的顺序来赋值。(c.toArray might (incorrectly) not return Object[] (see 6260652)不理解,待查资料)

  1. /**
  2. * Copies the components of this vector into the specified array.
  3. * The item at index {@code k} in this vector is copied into
  4. * component {@code k} of {@code anArray}.
  5. *
  6. * @param anArray the array into which the components get copied
  7. * @throws NullPointerException if the given array is null
  8. * @throws IndexOutOfBoundsException if the specified array is not
  9. * large enough to hold all the components of this vector
  10. * @throws ArrayStoreException if a component of this vector is not of
  11. * a runtime type that can be stored in the specified array
  12. * @see #toArray(Object[])
  13. */
  14. public synchronized void copyInto(Object[] anArray) {
  15. System.arraycopy(elementData, 0, anArray, 0, elementCount);
  16. }

将vector的内容复制给另一指定数组。

  1. /**
  2. * Trims the capacity of this vector to be the vector's current
  3. * size. If the capacity of this vector is larger than its current
  4. * size, then the capacity is changed to equal the size by replacing
  5. * its internal data array, kept in the field {@code elementData},
  6. * with a smaller one. An application can use this operation to
  7. * minimize the storage of a vector.
  8. */
  9. public synchronized void trimToSize() {
  10. modCount++;
  11. int oldCapacity = elementData.length;
  12. if (elementCount < oldCapacity) {
  13. elementData = Arrays.copyOf(elementData, elementCount);
  14. }
  15. }

如果vector的容量大于实际存储的元素数量,那么就将vector的容量调整为实际存储的元素数量,通过对内部数组重新赋值来实现,可以通过该操作最小化vector所占的内存。

  1. /**
  2. * Increases the capacity of this vector, if necessary, to ensure
  3. * that it can hold at least the number of components specified by
  4. * the minimum capacity argument.
  5. *
  6. * <p>If the current capacity of this vector is less than
  7. * {@code minCapacity}, then its capacity is increased by replacing its
  8. * internal data array, kept in the field {@code elementData}, with a
  9. * larger one. The size of the new data array will be the old size plus
  10. * {@code capacityIncrement}, unless the value of
  11. * {@code capacityIncrement} is less than or equal to zero, in which case
  12. * the new capacity will be twice the old capacity; but if this new size
  13. * is still smaller than {@code minCapacity}, then the new capacity will
  14. * be {@code minCapacity}.
  15. *
  16. * @param minCapacity the desired minimum capacity
  17. */
  18. public synchronized void ensureCapacity(int minCapacity) {
  19. if (minCapacity > 0) {
  20. modCount++;
  21. ensureCapacityHelper(minCapacity);
  22. }
  23. }
  24.  
  25. /**
  26. * This implements the unsynchronized semantics of ensureCapacity.
  27. * Synchronized methods in this class can internally call this
  28. * method for ensuring capacity without incurring the cost of an
  29. * extra synchronization.
  30. *
  31. * @see #ensureCapacity(int)
  32. */
  33. private void ensureCapacityHelper(int minCapacity) {
  34. // overflow-conscious code
  35. if (minCapacity - elementData.length > 0)
  36. grow(minCapacity);
  37. }
  38.  
  39. /**
  40. * The maximum size of array to allocate.
  41. * Some VMs reserve some header words in an array.
  42. * Attempts to allocate larger arrays may result in
  43. * OutOfMemoryError: Requested array size exceeds VM limit
  44. */
  45. private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
  46.  
  47. private void grow(int minCapacity) {
  48. // overflow-conscious code
  49. int oldCapacity = elementData.length;
  50. int newCapacity = oldCapacity + ((capacityIncrement > 0) ?
  51. capacityIncrement : oldCapacity);
  52. if (newCapacity - minCapacity < 0)
  53. newCapacity = minCapacity;
  54. if (newCapacity - MAX_ARRAY_SIZE > 0)
  55. newCapacity = hugeCapacity(minCapacity);
  56. elementData = Arrays.copyOf(elementData, newCapacity);
  57. }
  58.  
  59. private static int hugeCapacity(int minCapacity) {
  60. if (minCapacity < 0) // overflow
  61. throw new OutOfMemoryError();
  62. return (minCapacity > MAX_ARRAY_SIZE) ?
  63. Integer.MAX_VALUE :
  64. MAX_ARRAY_SIZE;
  65. }

增加vector的容量,如果有必要,要保证增加后的容量由minCapacity给出的最小容量。如果vector当前的容量小于minCapacity,就通过对内部数组重新赋值一个更大的数组的方式来扩容。当capacityIncrement小于等于0时,新数组的大小是之前的2倍,大于0时新数组的大小等于旧数组的大小与capacityIncrement只和。如果增加后的数组容量仍然小于minCapacity,那么新数组的大小为minCapacity。(ensureCapacityHelper方法不加synchronized是因为ensureCapacity方法加了synchronized,而且ensureCapacityHelper方法是在ensureCapacity内部调用的,因而没必要增加额外的synchronized)

而设置MAX_ARRAY_SIZE是因为,vector内部元素的数量elementCount和容量都是int型因而不能超出int的范围,而减8是因为某些VM里设有头结点,所以要留出这部分的空间。

hugeCapacity方法中判断minCapacity是否小于零则是因为负数减MAX_ARRAY_SIZE也可能大于0,例如

但是这里又为什么返回了Integer.MAX_VALUE呢(待解决)

  1. /**
  2. * Sets the size of this vector. If the new size is greater than the
  3. * current size, new {@code null} items are added to the end of
  4. * the vector. If the new size is less than the current size, all
  5. * components at index {@code newSize} and greater are discarded.
  6. *
  7. * @param newSize the new size of this vector
  8. * @throws ArrayIndexOutOfBoundsException if the new size is negative
  9. */
  10. public synchronized void setSize(int newSize) {
  11. modCount++;
  12. if (newSize > elementCount) {
  13. ensureCapacityHelper(newSize);
  14. } else {
  15. for (int i = newSize ; i < elementCount ; i++) {
  16. elementData[i] = null;
  17. }
  18. }
  19. elementCount = newSize;
  20. }

setSize方法用来修改当前vector的大小,如果newSize大于当前元素数量elementCount那么调用ensureCapacityHelper方法进行扩容(此时没有经过ensureCapacity方法),当newSize小于elementCount时,将数组下标大于等于newSize的元素的值设为null,两种情况最后都要将elementCount大小改为newSize。

  1. /**
  2. * Returns the current capacity of this vector.
  3. *
  4. * @return the current capacity (the length of its internal
  5. * data array, kept in the field {@code elementData}
  6. * of this vector)
  7. */
  8. public synchronized int capacity() {
  9. return elementData.length;
  10. }
  11.  
  12. /**
  13. * Returns the number of components in this vector.
  14. *
  15. * @return the number of components in this vector
  16. */
  17. public synchronized int size() {
  18. return elementCount;
  19. }
  20.  
  21. /**
  22. * Tests if this vector has no components.
  23. *
  24. * @return {@code true} if and only if this vector has
  25. * no components, that is, its size is zero;
  26. * {@code false} otherwise.
  27. */
  28. public synchronized boolean isEmpty() {
  29. return elementCount == 0;
  30. }

以上三个方法分别返回vector容量、元素数量elementCount以及判断vector是否为空。

  1. /**
  2. * Returns an enumeration of the components of this vector. The
  3. * returned {@code Enumeration} object will generate all items in
  4. * this vector. The first item generated is the item at index {@code 0},
  5. * then the item at index {@code 1}, and so on.
  6. *
  7. * @return an enumeration of the components of this vector
  8. * @see Iterator
  9. */
  10. public Enumeration<E> elements() {
  11. return new Enumeration<E>() {
  12. int count = 0;
  13.  
  14. public boolean hasMoreElements() {
  15. return count < elementCount;
  16. }
  17.  
  18. public E nextElement() {
  19. synchronized (Vector.this) {
  20. if (count < elementCount) {
  21. return elementData(count++);
  22. }
  23. }
  24. throw new NoSuchElementException("Vector Enumeration");
  25. }
  26. };
  27. }

该方法返回vector内部元素按下标顺序的Enumeration(类似枚举类型)

  1. /**
  2. * Returns the index of the first occurrence of the specified element in
  3. * this vector, searching forwards from {@code index}, or returns -1 if
  4. * the element is not found.
  5. * More formally, returns the lowest index {@code i} such that
  6. * <tt>(i&nbsp;&gt;=&nbsp;index&nbsp;&amp;&amp;&nbsp;(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i))))</tt>,
  7. * or -1 if there is no such index.
  8. *
  9. * @param o element to search for
  10. * @param index index to start searching from
  11. * @return the index of the first occurrence of the element in
  12. * this vector at position {@code index} or later in the vector;
  13. * {@code -1} if the element is not found.
  14. * @throws IndexOutOfBoundsException if the specified index is negative
  15. * @see Object#equals(Object)
  16. */
  17. public synchronized int indexOf(Object o, int index) {
  18. if (o == null) {
  19. for (int i = index ; i < elementCount ; i++)
  20. if (elementData[i]==null)
  21. return i;
  22. } else {
  23. for (int i = index ; i < elementCount ; i++)
  24. if (o.equals(elementData[i]))
  25. return i;
  26. }
  27. return -1;
  28. }

indexOf方法从给定index开始查找vector内是否存有Object o(可以为空),如果有则返回第一次出现的下标,如果不存在返回-1。

  1. /**
  2. * Returns {@code true} if this vector contains the specified element.
  3. * More formally, returns {@code true} if and only if this vector
  4. * contains at least one element {@code e} such that
  5. * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
  6. *
  7. * @param o element whose presence in this vector is to be tested
  8. * @return {@code true} if this vector contains the specified element
  9. */
  10. public boolean contains(Object o) {
  11. return indexOf(o, 0) >= 0;
  12. }
  13.  
  14. /**
  15. * Returns the index of the first occurrence of the specified element
  16. * in this vector, or -1 if this vector does not contain the element.
  17. * More formally, returns the lowest index {@code i} such that
  18. * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
  19. * or -1 if there is no such index.
  20. *
  21. * @param o element to search for
  22. * @return the index of the first occurrence of the specified element in
  23. * this vector, or -1 if this vector does not contain the element
  24. */
  25. public int indexOf(Object o) {
  26. return indexOf(o, 0);
  27. }

这两个方法都调用上边的indexOf方法,contains判断是否包含Object o,如果存在,返回true,否则返回false,indexOf也判断是否包含Object o,如果包含则返回第一次出现的下标,不存在返回-1。

  1. /**
  2. * Returns the index of the last occurrence of the specified element in
  3. * this vector, searching backwards from {@code index}, or returns -1 if
  4. * the element is not found.
  5. * More formally, returns the highest index {@code i} such that
  6. * <tt>(i&nbsp;&lt;=&nbsp;index&nbsp;&amp;&amp;&nbsp;(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i))))</tt>,
  7. * or -1 if there is no such index.
  8. *
  9. * @param o element to search for
  10. * @param index index to start searching backwards from
  11. * @return the index of the last occurrence of the element at position
  12. * less than or equal to {@code index} in this vector;
  13. * -1 if the element is not found.
  14. * @throws IndexOutOfBoundsException if the specified index is greater
  15. * than or equal to the current size of this vector
  16. */
  17. public synchronized int lastIndexOf(Object o, int index) {
  18. if (index >= elementCount)
  19. throw new IndexOutOfBoundsException(index + " >= "+ elementCount);
  20.  
  21. if (o == null) {
  22. for (int i = index; i >= 0; i--)
  23. if (elementData[i]==null)
  24. return i;
  25. } else {
  26. for (int i = index; i >= 0; i--)
  27. if (o.equals(elementData[i]))
  28. return i;
  29. }
  30. return -1;
  31. }

lastIndexOf方法类似indexOf方法,区别在于lastIndexOf方法从后向前查找,因而返回的是最后一次出现的下标,不存在仍然返回-1。

  1. /**
  2. * Returns the index of the last occurrence of the specified element
  3. * in this vector, or -1 if this vector does not contain the element.
  4. * More formally, returns the highest index {@code i} such that
  5. * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
  6. * or -1 if there is no such index.
  7. *
  8. * @param o element to search for
  9. * @return the index of the last occurrence of the specified element in
  10. * this vector, or -1 if this vector does not contain the element
  11. */
  12. public synchronized int lastIndexOf(Object o) {
  13. return lastIndexOf(o, elementCount-1);
  14. }

该方法调用lastIndexOf发法,返回Object o最后一次出现的下标,不存在仍然返回-1。

  1. /**
  2. * Returns the component at the specified index.
  3. *
  4. * <p>This method is identical in functionality to the {@link #get(int)}
  5. * method (which is part of the {@link List} interface).
  6. *
  7. * @param index an index into this vector
  8. * @return the component at the specified index
  9. * @throws ArrayIndexOutOfBoundsException if the index is out of range
  10. * ({@code index < 0 || index >= size()})
  11. */
  12. public synchronized E elementAt(int index) {
  13. if (index >= elementCount) {
  14. throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount);
  15. }
  16.  
  17. return elementData(index);
  18. }
  19.  
  20. /**
  21. * Returns the first component (the item at index {@code 0}) of
  22. * this vector.
  23. *
  24. * @return the first component of this vector
  25. * @throws NoSuchElementException if this vector has no components
  26. */
  27. public synchronized E firstElement() {
  28. if (elementCount == 0) {
  29. throw new NoSuchElementException();
  30. }
  31. return elementData(0);
  32. }
  33.  
  34. /**
  35. * Returns the last component of the vector.
  36. *
  37. * @return the last component of the vector, i.e., the component at index
  38. * <code>size()&nbsp;-&nbsp;1</code>.
  39. * @throws NoSuchElementException if this vector is empty
  40. */
  41. public synchronized E lastElement() {
  42. if (elementCount == 0) {
  43. throw new NoSuchElementException();
  44. }
  45. return elementData(elementCount - 1);
  46. }

elementAt返回指定下标的元素,firstElement返回第一个元素,lastElement返回最后一个元素。

  1. /**
  2. * Sets the component at the specified {@code index} of this
  3. * vector to be the specified object. The previous component at that
  4. * position is discarded.
  5. *
  6. * <p>The index must be a value greater than or equal to {@code 0}
  7. * and less than the current size of the vector.
  8. *
  9. * <p>This method is identical in functionality to the
  10. * {@link #set(int, Object) set(int, E)}
  11. * method (which is part of the {@link List} interface). Note that the
  12. * {@code set} method reverses the order of the parameters, to more closely
  13. * match array usage. Note also that the {@code set} method returns the
  14. * old value that was stored at the specified position.
  15. *
  16. * @param obj what the component is to be set to
  17. * @param index the specified index
  18. * @throws ArrayIndexOutOfBoundsException if the index is out of range
  19. * ({@code index < 0 || index >= size()})
  20. */
  21. public synchronized void setElementAt(E obj, int index) {
  22. if (index >= elementCount) {
  23. throw new ArrayIndexOutOfBoundsException(index + " >= " +
  24. elementCount);
  25. }
  26. elementData[index] = obj;
  27. }

该方法用来修改指定index的值(注意,不能添加index >= elementCount时会抛出异常),该方法与List接口中的set方法功能一样,区别在于set方法参数顺序更接近数组的用法,此外set还会返回旧元素的值。

  1. /**
  2. * Deletes the component at the specified index. Each component in
  3. * this vector with an index greater or equal to the specified
  4. * {@code index} is shifted downward to have an index one
  5. * smaller than the value it had previously. The size of this vector
  6. * is decreased by {@code 1}.
  7. *
  8. * <p>The index must be a value greater than or equal to {@code 0}
  9. * and less than the current size of the vector.
  10. *
  11. * <p>This method is identical in functionality to the {@link #remove(int)}
  12. * method (which is part of the {@link List} interface). Note that the
  13. * {@code remove} method returns the old value that was stored at the
  14. * specified position.
  15. *
  16. * @param index the index of the object to remove
  17. * @throws ArrayIndexOutOfBoundsException if the index is out of range
  18. * ({@code index < 0 || index >= size()})
  19. */
  20. public synchronized void removeElementAt(int index) {
  21. modCount++;
  22. if (index >= elementCount) {
  23. throw new ArrayIndexOutOfBoundsException(index + " >= " +
  24. elementCount);
  25. }
  26. else if (index < 0) {
  27. throw new ArrayIndexOutOfBoundsException(index);
  28. }
  29. int j = elementCount - index - 1;
  30. if (j > 0) {
  31. System.arraycopy(elementData, index + 1, elementData, index, j);
  32. }
  33. elementCount--;
  34. elementData[elementCount] = null; /* to let gc do its work */
  35. }

该方法通过将给定index(不包括index)后的所有有效元素前移的方式达到删除下标为index的元素的目的。

  1. /**
  2. * Inserts the specified object as a component in this vector at the
  3. * specified {@code index}. Each component in this vector with
  4. * an index greater or equal to the specified {@code index} is
  5. * shifted upward to have an index one greater than the value it had
  6. * previously.
  7. *
  8. * <p>The index must be a value greater than or equal to {@code 0}
  9. * and less than or equal to the current size of the vector. (If the
  10. * index is equal to the current size of the vector, the new element
  11. * is appended to the Vector.)
  12. *
  13. * <p>This method is identical in functionality to the
  14. * {@link #add(int, Object) add(int, E)}
  15. * method (which is part of the {@link List} interface). Note that the
  16. * {@code add} method reverses the order of the parameters, to more closely
  17. * match array usage.
  18. *
  19. * @param obj the component to insert
  20. * @param index where to insert the new component
  21. * @throws ArrayIndexOutOfBoundsException if the index is out of range
  22. * ({@code index < 0 || index > size()})
  23. */
  24. public synchronized void insertElementAt(E obj, int index) {
  25. modCount++;
  26. if (index > elementCount) {
  27. throw new ArrayIndexOutOfBoundsException(index
  28. + " > " + elementCount);
  29. }
  30. ensureCapacityHelper(elementCount + 1);
  31. System.arraycopy(elementData, index, elementData, index + 1, elementCount - index);
  32. elementData[index] = obj;
  33. elementCount++;
  34. }

该方法将index及其后的所有有效元素后移一位,然后将obj对象赋值给下标为index元素,从而实现插入元素(当index=elementCount效果等同于在最后添加一个元素)

数据结构复习之Vector的更多相关文章

  1. 数据结构逆向分析-Vector

    数据结构逆向分析-Vector 这个应该是家喻户晓了的东西把,如果说C/C++程序员Vector都不用的话,可能就是一个不太好的程序员. Vector就是一个STL封装的动态数组,数组大家都知道是通过 ...

  2. Java 常用数据结构深入分析(Vector、ArrayList、List、Map)

    线性表,链表,哈希表是常用的数据结构,在进行Java开发时,JDK已经为我们提供了一系列相应的类来实现基本的数据结构.这些类均在java.util包中.本文试图通过简单的描述,向读者阐述各个类的作用以 ...

  3. 数据结构复习:交换排序原理及C++实现

    1. 交换排序的基本思想 两两比较key值,如果发生逆序(排列的顺序与期望的顺序相反)就交换,知道所有对象都排序完毕!常见的3种交换排序算法:冒泡排序,shaker排序和快速排序. 2. 冒泡排序 设 ...

  4. 数据结构复习:希尔排序的C++实现

    1.原理介绍 希尔排序又称为缩小增量排序,由D.L.Shell在1959年提出而得名. 该算法先取一个小于数据表中元素个数 n 的整数gap, 并以此作为第一个间隔,将数据分为gap个子序列,所有距离 ...

  5. 数据结构复习:直接插入排序与二分插入排序的C++实现

    1.直接插入排序 直接插入排序的过程可以理解为一个固定长度的数组被分为两个集合,即已排序集合和未排序. 开始时已排序集合为空,而未排序集合即为整个数组.当排序开始后插入一个对象,已排序集合元素数目加1 ...

  6. 数据结构复习之C语言指针与结构体

    数据结构指针复习: #include <stdio.h> void main() { ] = {, , , , }; // a[3] == *(3+a) printf(+a)); // a ...

  7. 从零开始学习R语言(一)——数据结构之“向量”(Vector)

    本文首发于知乎专栏:https://zhuanlan.zhihu.com/p/59688569 也同步更新于我的个人博客:https://www.cnblogs.com/nickwu/p/125370 ...

  8. c语言数据结构复习

    1)线性表 //顺序存储下线性表的操作实现 #include <stdio.h> #include <stdlib.h> typedef int ElemType; /*线性表 ...

  9. NOIP 考前 数据结构复习

    BZOJ 1455 左偏树即可 #include <cstdio> #define LL long long ; struct Info{LL l,r,v,Dis;}Tree[Maxn]; ...

随机推荐

  1. C# 为所有 CheckBox 添加事件

    C# 为 form 窗体中的所有相同组件循环添加相同事件,这样减少了代码量. private void Form2_Load(object sender, EventArgs e) { foreach ...

  2. 含服务端,客户端,数据库的注册/登录/聊天/在线/离线查看的聊天demo

    用websocket,mysql,node的写了一个简单聊天的demo 实现了: 注册,登陆功能: 聊天信息广播: 在线/离线状态的查看: 服务端: 主要引用http,fs,mysql,socket. ...

  3. 读 vue 源码一 (为什么this.message能够访问data里面的message)

    12月离职后,打算在年后再找工作了,最近陆陆续续的看了黄轶老师的vue源码解析,趁着还有几天过年时间记录一下. 目标:vue如何实现通过this.key,就能直接访问data,props,method ...

  4. Haystack全文检索

    1.什么是Haystack Haystack是django的开源全文搜索框架(全文检索不同于特定字段的模糊查询,使用全文检索的效率更高 ),该框架支持Solr,Elasticsearch(java写的 ...

  5. 使用win10的开始屏幕,在系统中设置简洁、快捷桌面

    前几天入手了一个本本,由于之前电脑使用的柠檬桌面软件和现在本本的分辨率不适应,意外发现win10自带的开始屏幕整理桌面也是很有意思,再加上触摸板的手势,瞬间觉得整个电脑都清洁许多.废话少说,开始上料. ...

  6. 数据类型(data type)

    基本数据类型(primitive data type):字符型(2个字节),布尔型(一位),byte(1个字节),short(两个字节),int(4个字节),long(8个字节),float(2个字节 ...

  7. 从Scratch到Python——Python生成二维码

    # Python利用pyqrcode模块生成二维码 import pyqrcode import sys number = pyqrcode.create('从Scratch到Python--Pyth ...

  8. Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app

    出现的问题: Error:Execution failed for task ':app:preDebugAndroidTestBuild'.> Conflict with dependency ...

  9. HttpClient MultipartEntityBuilder 上传文件

    文章转载自: http://blog.csdn.net/yan8024/article/details/46531901 http://www.51testing.com/html/56/n-3707 ...

  10. GT sport真实赛道详解 - Brands Hatch | 伯蘭士赫治GP賽車場

    参考:GT sport所有赛道简介 GT Sport - Tip/Guide For FASTER LAP TIMES (Brands Hatch) 赛道介绍.跑法.赛事网上都有大把的视频. GT s ...