Trim the underlying array to be the current size, or {@link #INITIAL_CAPACITY} if size is less.
489408
public void trimToSize()
    {
        if (elements.length != size && elements.length > INITIAL_CAPACITY)
        {
            elements = Arrays.copyOf(elements, Math.max(INITIAL_CAPACITY, size));
        }
    }
235132
public void shrink() {
        if (c.length == length) {
            return;
        }
        char[] newc = new char[length];
        System.arraycopy(c, 0, newc, 0, length);
        c = newc;
    }
967706
private void trim() {

        // Trim
        while (values.size() > limit.getMaxEntries()) {
            values.removeLast();
        }

        // Trim according to duration
        if (limit.getMaxDuration() > 0 && !values.isEmpty()) {
            long duration = limit.getMaxDuration();
            long start = values.getFirst().getTimestamp();
            while (start - values.getLast().getTimestamp() > duration) {
                values.removeLast();
            }
        }
    }
850419
public static <T> T subArray(final T array, final int start, final int end) {

    if (isEmpty(array) || start < 0 || start > end || end >= Array.getLength(array)) {
      return array;
    }
    int newArraySize = end - start + 1;
    @SuppressWarnings("unchecked")
    T newArray = (T) buildArray(ClassUtils.getPrimitiveClass(ClassUtils.getComponentClass(array)),
      newArraySize, null);
    System.arraycopy(array, start, newArray, 0, newArraySize);
    return newArray;
  }
4838
def shrink(self, new_size):
        
        self.size = new_size

        if self.sort == 'string':
            self.null_terminated = False # string without the null byte terminator
            self._content[0] = self._content[0][ : self.size]

        elif self.sort == 'pointer-array':
            pointer_size = self.binary.project.arch.bytes

            if self.size % pointer_size != 0:
                # it's not aligned?
                raise BinaryError('Fails at Data.shrink()')

            pointers = self.size // pointer_size
            self._content = self._content[ : pointers]

        else:
            # unknown
            self._content =  [ self._content[0][ : self.size ] ]
23329
static public int sizeOf(WsByteBuffer[] list) {
        if (null == list) {
            return 0;
        }
        int size = 0;
        for (int i = 0; i < list.length; i++) {
            if (null != list[i]) {
                size += list[i].remaining();
            }
        }
        return size;
    }
754240
function initial(array) {
      var length = array == null ? 0 : array.length;
      return length ? baseSlice(array, 0, -1) : [];
    }
244553
public void truncate(int size) {

        m_buffer.truncate(size);
        m_position = Math.min(size, m_position);
    }
973587
private int getSizeOfIntArrays() {
    return (offsets.length + hashcodes.length + nexts.length + counts.length +
        indexStrides.length) * 4;
  }
1253161
@Deprecated public static int size (Object[] list)
    {
        if (list == null) {
            return 0;
        }
        int llength = list.length;
        for (int ii = 0; ii < llength; ii++) {
            if (list[ii] == null) {
                return ii;
            }
        }
        return llength;
    }
72357
private int allocate(int size)
    {
        while (true)
        {
            int prev = allocatePosition.get();
            int next = prev + size;
            if (next >= buffer.capacity())
                return -1;
            if (allocatePosition.compareAndSet(prev, next))
                return prev;
        }
    }
298386
private static int[] ensureSize(int[] tab, int length) {
        if (tab.length < length) {
            tab = null;
            tab = new int[length];
        }

        return tab;
    }
631675
public static int getSize (Object[] list)
    {
        int size = 0;
        for (int ii = 0, nn = (list == null) ? 0 : list.length; ii < nn; ii++) {
            if (list[ii] != null) {
                size++;
            }
        }
        return size;
    }
862946
public void truncate(int newsize) {
    if(newsize < size) {
      double[] odists = dists;
      dists = new double[newsize];
      System.arraycopy(odists, 0, dists, 0, newsize);
      int[] oids = ids;
      ids = new int[newsize];
      System.arraycopy(oids, 0, ids, 0, newsize);
      size = newsize;
    }
  }
533238
public Integer getArraySizeAsInt() {
    if (this.arraySize == null) {
      throw new NullPointerException("Array size is not defined");
    }
    try {
      return Integer.valueOf(this.arraySize.trim());
    } catch (NumberFormatException ex) {
      return null;
    }
  }
590177
public int[] trimAndGet() {
    if (size < elementData.length) {
      elementData = Arrays.copyOf(elementData, size);
    }
    return elementData;
  }
561059
private void reallocate(int capacity) {
    if (capacity != elements.length) {
      assert (size <= capacity);
      float[] newArray = new float[capacity];
      for (int i = 0; i < size; i++) {
        newArray[i] = elements[i];
      }
      elements = newArray;
    }
  }