APISonar


java.util.ArrayList.trimToSize

> java > util > ArrayList > trimToSize
java APIs util APIs ArrayList APIs trimToSize APIs

Example 1
ArrayList<File> files = new ArrayList<>();

    public void trimToSize() {
        classes.trimToSize();
        for (Class c : classes) {
            c.trimToSize();
        }
        files.trimToSize();
    }
Example 2
public void trimToSize() {

        if (fast) {
            synchronized (this) {
                ArrayList temp = (ArrayList) list.clone();
                temp.trimToSize();
                list = temp;
            }
        } else {
            synchronized (list) {
                list.trimToSize();
            }
        }

    }
Example 3
protected /*@spec_public non_null@*/ ArrayList<Instance> m_Instances;

  public void compactify() {

    m_Instances.trimToSize();
  }
Example 4
public void trimToSize() {
    for (Collection<V> collection : backingMap().values()) {
      ArrayList<V> arrayList = (ArrayList<V>) collection;
      arrayList.trimToSize();
    }
  }
Example 5
private final ArrayList<DecoratedKey> keys;

    public void complete()
    {
        keys.trimToSize();
        positions.trimToSize();
    }
Example 6
private ArrayList<UndoableEdit> edits; // ArrayList due to trim

    public void end() {
	clearStatusBits(IN_PROGRESS);
        edits.trimToSize();
    }
Example 7
private static <T> List<T> optimizeList(ArrayList<T> list) {
        switch(list.size()) {
            case 0: {
                return Collections.emptyList();
            }
            case 1: {
                return Collections.singletonList(list.get(0));
            }
            default: {
                list.trimToSize();
                return list;
            }
        }
    }
Example 8
private ArrayList<KeyPosition> indexPositions;

    public void complete()
    {
        indexPositions.trimToSize();
    }
Example 9
public static <T> List<T> concat(List<T> l1, List<T> l2) {
        ArrayList<T> l = new ArrayList<>(l1);
        l.addAll(l2);
        l.trimToSize();
        return l;
    }
Example 10
public void test_trimToSize_02() {
        ArrayList list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
                "d", "e", "f", "g" }));
        list.remove("a");
        list.remove("f");
        list.trimToSize();
    }
Example 11
private ArrayList<DefaultHistoryReferencesTableEntry> hrefList;

    public void clear() {
        hrefList.clear();
        hrefList.trimToSize();

        historyIdToRow = new TreeMap<>();
        rowIndexes = new TreeSet<>();

        fireTableDataChanged();
    }
Example 12
private ArrayList<UndoLogRecord> records = New.arrayList();

    void removeLast(boolean trimToSize) {
        int i = records.size() - 1;
        UndoLogRecord r = records.remove(i);
        if (!r.isStored()) {
            memoryUndo--;
        }
        if (trimToSize && i > 1024 && (i & 1023) == 0) {
            records.trimToSize();
        }
    }
Example 13
ListLiteral(ArrayList<Expression> items) {
        this.items = items;
        items.trimToSize();
    }
Example 14
public void CompareQueryResultsAsListWithoutAndWithIndexes(Object[][] r, int len,
      boolean checkOrder, boolean checkClass, String queries[]) {
    Integer count1, count2;
    Iterator<Integer> itert1, itert2;
    ArrayList result1, result2;

    for (int j = 0; j < len; j++) {
      result1 = ((ArrayList) r[j][0]);
      result2 = ((ArrayList) r[j][1]);
      result1.trimToSize();
      result2.trimToSize();

      compareQueryResultLists(result1, result2, len, checkOrder, checkClass, queries[j]);
    }
  }
Example 15
public List<T> tokenize() {
    ArrayList<T> result = new ArrayList<>(DEFAULT_TOKENIZE_LIST_SIZE);
    while (hasNext()) {
      result.add(next());
    }
    // log.info("tokenize() produced " + result);
    // if it was tiny, reallocate small
    if (result.size() <= DEFAULT_TOKENIZE_LIST_SIZE / 4) {
      result.trimToSize();
    }
    return result;
  }
Example 16
public static ArrayList<Node> nodeListToDeadArray(NodeList nodes) {
        ArrayList<Node> rtnNodes = null;
        if (nodes != null) {
            rtnNodes = new ArrayList<Node>();
            for (int i = 0; i < nodes.getLength(); i++)
                rtnNodes.add(nodes.item(i).cloneNode(true));

            rtnNodes.trimToSize();
        }

        return rtnNodes;
    }
Example 17
public List<Extension> getLoadedExtensionsWithDeps() {
		List<String> classnames = getExtensionsWithDeps();
		ArrayList<Extension> loadedExtensions = new ArrayList<>(extensionsWithDeps.size());
		for (Extension extension : getLoadedExtensions()) {
			if (classnames.contains(extension.getClass().getCanonicalName())) {
				loadedExtensions.add(extension);
			}
		}
		loadedExtensions.trimToSize();
		return loadedExtensions;
	}
Example 18
private static final List removeDuplicates(List list) {
        int s = list.size();
        ArrayList ulist = new ArrayList(s);
        Set set = new HashSet(s * 4 / 3, .75f);
        Iterator it = list.iterator();
        while (it.hasNext()) {
            Object o = it.next();
            if (set.add(o))
                ulist.add(o);
        }
        ulist.trimToSize();
        return ulist;
    }
Example 19
public static <T> List<T> filter(List<T> list, ListLook<T> hook) {
        ArrayList<T> r = new ArrayList<>();
        for (T t : list) {
            if (hook.test(t)) {
                r.add(t);
            }
        }
        r.trimToSize();
        return r;
    }
Example 20
private final ArrayList<Fragment> myFragments;

  private void init() {
    Collections.sort(myFragments, FRAGMENT_COMPARATOR);
    myFragments.trimToSize();
  }
Example 21
ListLiteral(ArrayList values) {
        this.values = values;
        values.trimToSize();
    }
Example 22
private ArrayList<GridToStringFieldDescriptor> fields = new ArrayList<>();

    void sortFields() {
        fields.trimToSize();

        fields.sort(Comparator.comparingInt(GridToStringFieldDescriptor::getOrder));
    }
Example 23
private List getPath (String pathName) {
        String cp = saVM.getSystemProperty(pathName);
        String pathSep = saVM.getSystemProperty("path.separator");
        ArrayList al = new ArrayList();
        StringTokenizer st = new StringTokenizer(cp, pathSep);
        while (st.hasMoreTokens()) {
            al.add(st.nextToken());
        }
        al.trimToSize();
        return al;
    }
Example 24
public List<Method> methodsByName(String name, String signature) {
        List<Method> methods = visibleMethods();
        ArrayList<Method> retList = new ArrayList<Method>(methods.size());
        for (Method candidate : methods) {
            if (candidate.name().equals(name) &&
                candidate.signature().equals(signature)) {
                retList.add(candidate);
            }
        }
        retList.trimToSize();
        return retList;
    }
Example 25
private ArrayList<AreaEdge> edges = new ArrayList<AreaEdge>();

    private void writeObject(ObjectOutputStream out) throws IOException {
        edges.trimToSize();
        out.defaultWriteObject();
    }