Home | History | Annotate | Download | only in latin
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.inputmethod.latin;
     18 
     19 import android.util.SparseArray;
     20 
     21 import java.util.ArrayList;
     22 import java.util.Collection;
     23 import java.util.Collections;
     24 import java.util.HashMap;
     25 import java.util.HashSet;
     26 import java.util.LinkedList;
     27 import java.util.Map;
     28 import java.util.TreeMap;
     29 import java.util.TreeSet;
     30 import java.util.WeakHashMap;
     31 import java.util.concurrent.ConcurrentHashMap;
     32 import java.util.concurrent.CopyOnWriteArrayList;
     33 
     34 public final class CollectionUtils {
     35     private CollectionUtils() {
     36         // This utility class is not publicly instantiable.
     37     }
     38 
     39     public static <K,V> HashMap<K,V> newHashMap() {
     40         return new HashMap<K,V>();
     41     }
     42 
     43     public static <K, V> WeakHashMap<K, V> newWeakHashMap() {
     44         return new WeakHashMap<K, V>();
     45     }
     46 
     47     public static <K,V> TreeMap<K,V> newTreeMap() {
     48         return new TreeMap<K,V>();
     49     }
     50 
     51     public static <K, V> Map<K,V> newSynchronizedTreeMap() {
     52         final TreeMap<K,V> treeMap = newTreeMap();
     53         return Collections.synchronizedMap(treeMap);
     54     }
     55 
     56     public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap() {
     57         return new ConcurrentHashMap<K,V>();
     58     }
     59 
     60     public static <E> HashSet<E> newHashSet() {
     61         return new HashSet<E>();
     62     }
     63 
     64     public static <E> TreeSet<E> newTreeSet() {
     65         return new TreeSet<E>();
     66     }
     67 
     68     public static <E> ArrayList<E> newArrayList() {
     69         return new ArrayList<E>();
     70     }
     71 
     72     public static <E> ArrayList<E> newArrayList(final int initialCapacity) {
     73         return new ArrayList<E>(initialCapacity);
     74     }
     75 
     76     public static <E> ArrayList<E> newArrayList(final Collection<E> collection) {
     77         return new ArrayList<E>(collection);
     78     }
     79 
     80     public static <E> LinkedList<E> newLinkedList() {
     81         return new LinkedList<E>();
     82     }
     83 
     84     public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
     85         return new CopyOnWriteArrayList<E>();
     86     }
     87 
     88     public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
     89             final Collection<E> collection) {
     90         return new CopyOnWriteArrayList<E>(collection);
     91     }
     92 
     93     public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final E[] array) {
     94         return new CopyOnWriteArrayList<E>(array);
     95     }
     96 
     97     public static <E> SparseArray<E> newSparseArray() {
     98         return new SparseArray<E>();
     99     }
    100 }
    101