Author: schor Date: Tue Feb 16 15:56:00 2016 New Revision: 1730704 URL: http://svn.apache.org/viewvc?rev=1730704&view=rev Log: [UIMA-4674] for performance, add ability to set initial capacity
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjListMap.java Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjListMap.java URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjListMap.java?rev=1730704&r1=1730703&r2=1730704&view=diff ============================================================================== --- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjListMap.java (original) +++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/internal/util/Int2ObjListMap.java Tue Feb 16 15:56:00 2016 @@ -41,22 +41,30 @@ import org.apache.uima.util.Misc; */ public class Int2ObjListMap<T> { - private final ArrayList<T> values = new ArrayList<>(); + private final ArrayList<T> values; + + public Int2ObjListMap() { + values = new ArrayList<>(); + } + + public Int2ObjListMap(int initialSize) { + values = new ArrayList<>(initialSize); + } public void clear() { values.clear(); } - public T get(int key) { - return (key < 0 || key >= values.size()) - ? null - : values.get(key); - } - - public T put(int key, T value) { - T prev = get(key); - Misc.setWithExpand(values, key, value); - return prev; - } + public T get(int key) { + return (key < 0 || key >= values.size()) + ? null + : values.get(key); + } + + public T put(int key, T value) { + T prev = get(key); + Misc.setWithExpand(values, key, value); + return prev; + } }