APISonar


java.util.ArrayList.ensureCapacity

> java > util > ArrayList > ensureCapacity
java APIs util APIs ArrayList APIs ensureCapacity APIs

Example 1
protected ArrayList buffer;

  public void setBufferSize(int newBufferSize) {
    bufferSize = newBufferSize;
    buffer.ensureCapacity(bufferSize);
    removes.ensureCapacity(bufferSize);
  }
Example 2
private final ArrayList<Object[]> blockBuffer;

    private void resizeBlockBuffer() {
        rowAccounting.release();
        blockBufferMaxSize = blockSizeCalculator.getAsInt();
        blockBuffer.clear();
        blockBuffer.ensureCapacity(blockBufferMaxSize);
        bufferPos = -1;
    }
Example 3
private ArrayList parameters = new ArrayList();

    void setBoolean(int parameterIndex, Boolean x) {
        parameters.ensureCapacity(parameterIndex+1);
        parameters.add(x);
    }
Example 4
private ArrayList<Boolean> marks_;

  private void growDataArrays() {
    currItemsAlloc_ = SamplingUtil.getAdjustedSize(k_, currItemsAlloc_ << rf_.lg());
    if (currItemsAlloc_ == k_) {
      ++currItemsAlloc_;
    }

    data_.ensureCapacity(currItemsAlloc_);
    weights_.ensureCapacity(currItemsAlloc_);
    if (marks_ != null) {
      marks_.ensureCapacity(currItemsAlloc_);
    }
  }
Example 5
private ArrayList rows = new ArrayList();

    public void setModel(TableModel tm) {
        super.setModel(tm);
        rows.ensureCapacity(model.getRowCount());
        model.addTableModelListener(this);
        sortColumn = -1;
        dirty = true;
        refresh();
    }
Example 6
private final ArrayList tsJindexes;   // ArrayList of Integer

   public WarpPath(int initialCapacity)
   {
      this();
      tsIindexes.ensureCapacity(initialCapacity);
      tsJindexes.ensureCapacity(initialCapacity);

   }
Example 7
ArrayList<E> storage = new ArrayList<>();

	public boolean addAll(Collection<? extends E> c) {
		storage.ensureCapacity(storage.size() + c.size());
		c.forEach(this::add);
		return true;
	}
Example 8
private ArrayList<View> mTouchDispatchList = new ArrayList<>(2);

    public ArrayList<View> buildTouchDispatchChildList() {
        mTouchDispatchList.ensureCapacity(3);
        if (mCaption != null) {
            mTouchDispatchList.add(mCaption);
        }
        if (mContent != null) {
            mTouchDispatchList.add(mContent);
        }
        return mTouchDispatchList;
    }
Example 9
private ArrayList<Integer> counters = new ArrayList<>();

    private void capacity(int minCap) {
        counters.ensureCapacity(minCap);

        while (counters.size() < minCap)
            counters.add(0);
    }
Example 10
private static void resize(ArrayList<?> list, int minSize) {
        list.ensureCapacity(minSize);
        while (list.size() < minSize) {
            list.add(null);
        }
    }
Example 11
private ArrayList<Integer> getInterestingNativePids() {
        ArrayList<Integer> pids = getInterestingHalPids();

        int[] nativePids = Process.getPidsForCommands(NATIVE_STACKS_OF_INTEREST);
        if (nativePids != null) {
            pids.ensureCapacity(pids.size() + nativePids.length);
            for (int i : nativePids) {
                pids.add(i);
            }
        }

        return pids;
    }
Example 12
public Object resize(final Object list, final int newSize) {
    final ArrayList l = (ArrayList) list;
    l.ensureCapacity(newSize);
    while (l.size() < newSize) {
      l.add(null);
    }
    while (l.size() > newSize) {
      l.remove(l.size() - 1);
    }
    return list;
  }
Example 13
private final ArrayList<Entry> myChildren;

  public void addChildren(Collection<Entry> children) {
    myChildren.ensureCapacity(myChildren.size() + children.size());
    for (Entry each : children) {
      unsafeAddChild(each);
    }
  }
Example 14
static void copyToByteArrayList(byte[] inputArray, ArrayList<Byte> outputArray) {
        outputArray.clear();
        outputArray.ensureCapacity(inputArray.length);
        for (byte element : inputArray) {
            outputArray.add(element);
        }
    }
Example 15
private ArrayList list = new ArrayList() ;

    private void extend( int index )
    {
        if (index >= list.size()) {
            list.ensureCapacity( index + 1 ) ;
            int max = list.size() ;
            while (max++ <= index)
                list.add( null ) ;
        }
    }
Example 16
static void ensureCapacity(ArrayList<Object> list, int capacity) {
        int oldCapacity = capacity(list);
        int oldModCount = modCount(list);
        list.ensureCapacity(capacity);
        assertTrue(capacity(list) >= capacity || capacity(list) == 0);
        assertEquals(modCount(list),
                     (capacity(list) == oldCapacity)
                     ? oldModCount
                     : oldModCount + 1);
    }
Example 17
protected static <T> void grow(ArrayList<T> list, int size)
    {
        int previousSize = list.size();

        list.ensureCapacity(size);
        List<T> l = Collections.nCopies(size - previousSize, null);
        list.addAll(l);
    }
Example 18
private final ArrayList<String> charClass = new ArrayList<String>();

   private void padCharClass(int len)
   {
      int curSize = charClass.size();
      if (curSize >= len)
         return;
      charClass.ensureCapacity(len);
      for (int i = 0; i < (len - curSize); i++)
         charClass.add(null);
   }
Example 19
public <E> ArrayList<E> arrayList(int minCapacity) {
        ArrayList<E> list = (ArrayList<E>) arrayList;
        if (list == null) {
            arrayList = new ArrayList<Object>(minCapacity);
            return (ArrayList<E>) arrayList;
        }
        list.clear();
        list.ensureCapacity(minCapacity);
        return list;
    }
Example 20
public static Iterator<Object[]> navigableSetsProvider() {
        ArrayList<Object[]> iters = new ArrayList<>(makeCheckedSets());
        iters.ensureCapacity(numItr * iters.size());
        for (int each=1; each < numItr; each++) {
            iters.addAll(makeCheckedSets());
        }
        return iters.iterator();
    }
Example 21
private void addToHeldIds(int theValueIdx, ArrayList<String> theListToAddTo, String theId) {
		theListToAddTo.ensureCapacity(theValueIdx);
		while (theListToAddTo.size() <= theValueIdx) {
			theListToAddTo.add(null);
		}
		if (theListToAddTo.get(theValueIdx) == null) {
			theListToAddTo.set(theValueIdx, theId);
		}
	}
Example 22
private static final <E> void moveAll(ArrayList<E> source, ArrayList<E> target) {
		target.ensureCapacity(target.size() + source.size());
		for (int i = source.size() - 1; i >= 0; i--) {
			target.add(source.remove(i));
		}
	}
Example 23
public Object[] getIds() {
        ArrayList<String> list = new ArrayList<String>();
        synchronized (context) {
            for (int scope : context.getScopes()) {
                Bindings bindings = context.getBindings(scope);
                if (bindings != null) {
                    list.ensureCapacity(bindings.size());
                    for (String key : bindings.keySet()) {
                        list.add(key);
                    }
                }
            }
        }
        return list.toArray(new String[list.size()]);
    }
Example 24
private final ArrayList<Boolean> mCheckStates;

    public Cursor swapCursor(Cursor newCursor) {
        if (newCursor != null) {
            int count = newCursor.getCount();
            mCheckStates.ensureCapacity(count);
            // initialize new fields to true (use case knowledge: we usually want to sign all uids)
            for (int i = mCheckStates.size(); i < count; i++) {
                mCheckStates.add(true);
            }
        }

        return super.swapCursor(newCursor);
    }
Example 25
private static void testArrayList() {
        ArrayList<String> al = new ArrayList<String>();
        al.add("abc");
        al.ensureCapacity(Integer.MIN_VALUE);

        // there is no method to query the capacity of ArrayList
        // so before and after capacity are not checked
    }