congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ArrayList.ensureCapacityInternal
Code IndexAdd Tabnine to your IDE (free)

How to use
ensureCapacityInternal
method
in
java.util.ArrayList

Best Java code snippets using java.util.ArrayList.ensureCapacityInternal (Showing top 11 results out of 315)

origin: jtulach/bck2brwsr

/**
 * Increases the capacity of this <tt>ArrayList</tt> instance, if
 * necessary, to ensure that it can hold at least the number of elements
 * specified by the minimum capacity argument.
 *
 * @param   minCapacity   the desired minimum capacity
 */
public void ensureCapacity(int minCapacity) {
  if (minCapacity > 0)
    ensureCapacityInternal(minCapacity);
}
origin: org.apidesign.bck2brwsr/emul

/**
 * Increases the capacity of this <tt>ArrayList</tt> instance, if
 * necessary, to ensure that it can hold at least the number of elements
 * specified by the minimum capacity argument.
 *
 * @param   minCapacity   the desired minimum capacity
 */
public void ensureCapacity(int minCapacity) {
  if (minCapacity > 0)
    ensureCapacityInternal(minCapacity);
}
origin: jtulach/bck2brwsr

/**
 * Appends the specified element to the end of this list.
 *
 * @param e element to be appended to this list
 * @return <tt>true</tt> (as specified by {@link Collection#add})
 */
public boolean add(E e) {
  ensureCapacityInternal(size + 1);  // Increments modCount!!
  elementData[size++] = e;
  return true;
}
origin: org.apidesign.bck2brwsr/emul

/**
 * Appends the specified element to the end of this list.
 *
 * @param e element to be appended to this list
 * @return <tt>true</tt> (as specified by {@link Collection#add})
 */
public boolean add(E e) {
  ensureCapacityInternal(size + 1);  // Increments modCount!!
  elementData[size++] = e;
  return true;
}
origin: org.apidesign.bck2brwsr/emul

/**
 * Appends all of the elements in the specified collection to the end of
 * this list, in the order that they are returned by the
 * specified collection's Iterator.  The behavior of this operation is
 * undefined if the specified collection is modified while the operation
 * is in progress.  (This implies that the behavior of this call is
 * undefined if the specified collection is this list, and this
 * list is nonempty.)
 *
 * @param c collection containing elements to be added to this list
 * @return <tt>true</tt> if this list changed as a result of the call
 * @throws NullPointerException if the specified collection is null
 */
public boolean addAll(Collection<? extends E> c) {
  Object[] a = c.toArray();
  int numNew = a.length;
  ensureCapacityInternal(size + numNew);  // Increments modCount
  System.arraycopy(a, 0, elementData, size, numNew);
  size += numNew;
  return numNew != 0;
}
origin: jtulach/bck2brwsr

/**
 * Appends all of the elements in the specified collection to the end of
 * this list, in the order that they are returned by the
 * specified collection's Iterator.  The behavior of this operation is
 * undefined if the specified collection is modified while the operation
 * is in progress.  (This implies that the behavior of this call is
 * undefined if the specified collection is this list, and this
 * list is nonempty.)
 *
 * @param c collection containing elements to be added to this list
 * @return <tt>true</tt> if this list changed as a result of the call
 * @throws NullPointerException if the specified collection is null
 */
public boolean addAll(Collection<? extends E> c) {
  Object[] a = c.toArray();
  int numNew = a.length;
  ensureCapacityInternal(size + numNew);  // Increments modCount
  System.arraycopy(a, 0, elementData, size, numNew);
  size += numNew;
  return numNew != 0;
}
origin: stackoverflow.com

 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
  at java.util.Arrays.copyOf(Arrays.java:2245)
  at java.util.Arrays.copyOf(Arrays.java:2219)
  at java.util.ArrayList.grow(ArrayList.java:213)
  at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:187)
  at java.util.ArrayList.add(ArrayList.java:411)
  at test.Test.main(OOME.java:26)
Java Result: 1
origin: org.apidesign.bck2brwsr/emul

/**
 * 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) {
  rangeCheckForAdd(index);
  ensureCapacityInternal(size + 1);  // Increments modCount!!
  System.arraycopy(elementData, index, elementData, index + 1,
           size - index);
  elementData[index] = element;
  size++;
}
origin: jtulach/bck2brwsr

/**
 * 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) {
  rangeCheckForAdd(index);
  ensureCapacityInternal(size + 1);  // Increments modCount!!
  System.arraycopy(elementData, index, elementData, index + 1,
           size - index);
  elementData[index] = element;
  size++;
}
origin: jtulach/bck2brwsr

/**
 * Inserts all of the elements in the specified collection into this
 * list, starting at the specified position.  Shifts the element
 * currently at that position (if any) and any subsequent elements to
 * the right (increases their indices).  The new elements will appear
 * in the list in the order that they are returned by the
 * specified collection's iterator.
 *
 * @param index index at which to insert the first element from the
 *              specified collection
 * @param c collection containing elements to be added to this list
 * @return <tt>true</tt> if this list changed as a result of the call
 * @throws IndexOutOfBoundsException {@inheritDoc}
 * @throws NullPointerException if the specified collection is null
 */
public boolean addAll(int index, Collection<? extends E> c) {
  rangeCheckForAdd(index);
  Object[] a = c.toArray();
  int numNew = a.length;
  ensureCapacityInternal(size + numNew);  // Increments modCount
  int numMoved = size - index;
  if (numMoved > 0)
    System.arraycopy(elementData, index, elementData, index + numNew,
             numMoved);
  System.arraycopy(a, 0, elementData, index, numNew);
  size += numNew;
  return numNew != 0;
}
origin: org.apidesign.bck2brwsr/emul

/**
 * Inserts all of the elements in the specified collection into this
 * list, starting at the specified position.  Shifts the element
 * currently at that position (if any) and any subsequent elements to
 * the right (increases their indices).  The new elements will appear
 * in the list in the order that they are returned by the
 * specified collection's iterator.
 *
 * @param index index at which to insert the first element from the
 *              specified collection
 * @param c collection containing elements to be added to this list
 * @return <tt>true</tt> if this list changed as a result of the call
 * @throws IndexOutOfBoundsException {@inheritDoc}
 * @throws NullPointerException if the specified collection is null
 */
public boolean addAll(int index, Collection<? extends E> c) {
  rangeCheckForAdd(index);
  Object[] a = c.toArray();
  int numNew = a.length;
  ensureCapacityInternal(size + numNew);  // Increments modCount
  int numMoved = size - index;
  if (numMoved > 0)
    System.arraycopy(elementData, index, elementData, index + numNew,
             numMoved);
  System.arraycopy(a, 0, elementData, index, numNew);
  size += numNew;
  return numNew != 0;
}
java.utilArrayListensureCapacityInternal

Popular methods of ArrayList

  • <init>
  • add
  • size
    Returns the number of elements in this ArrayList.
  • get
    Returns the element at the specified position in this list.
  • toArray
    Returns an array containing all of the elements in this list in proper sequence (from first to last
  • addAll
    Adds the objects in the specified collection to this ArrayList.
  • remove
    Removes the first occurrence of the specified element from this list, if it is present. If the list
  • clear
    Removes all elements from this ArrayList, leaving it empty.
  • isEmpty
    Returns true if this list contains no elements.
  • iterator
    Returns an iterator over the elements in this list in proper sequence.The returned iterator is fail-
  • contains
    Searches this ArrayList for the specified object.
  • set
    Replaces the element at the specified position in this list with the specified element.
  • contains,
  • set,
  • indexOf,
  • clone,
  • subList,
  • stream,
  • ensureCapacity,
  • trimToSize,
  • removeAll,
  • toString

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JTextField (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now