package com.pictc.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CopyOnWriteArrayList;

public class CollectionUtils{
	
	public static <T>List<T> newVector(){
		return new Vector<T>();
	}
	
	public static <T>List<T> newConcurrentArrayList(){
		return new CopyOnWriteArrayList<T>();
	}
	
	public static <T>List<T> newArrayList(){
		return new ArrayList<T>();
	}
	
	public static <T>List<T> newArrayList(int size){
		return new ArrayList<T>(size);
	}
	
	public static <T>List<T> newLinkedList(){
		return new LinkedList<T>();
	}
	
	
	public static <V, K>Map<K,V> newHashMap(){
		return new HashMap<K,V>();
	}
	
	public static <V, K> Map<K,V> newHashtable(){
		return new Hashtable<K,V>();
	}
	
	public static <V, K> Map<K,V> newIdentityHashMap(){
		return new IdentityHashMap<K,V>();
	}
	
	public static <V, K> Map<K,V> newLinkedHashMap(){
		return new LinkedHashMap<K,V>();
	}
	
	public static <V, K> Map<K,V> newTreeMap(){
		return new TreeMap<K,V>();
	}
	
	public static <V, K> Map<K,V> newWeakHashMap(){
		return new WeakHashMap<K,V>();
	}
	
	public static <V, K> Map<K,V> newConcurrentHashMap(){
		return new ConcurrentHashMap<K,V>();
	}

	public static Properties newProperties(){
		return new Properties();
	}


	public static <T> Set<T> newHashSet(){
		return new HashSet<T>();
	}
	
	public static <T> Set<T> newLinkedHashSet(){
		return new LinkedHashSet<T>();
	}
	
	public static <T> Set<T> newTreeSet(){
		return new TreeSet<T>();
	}

	public static <T> Set<T> newConcurrentSet(){
		return new ConcurrentSkipListSet<T>();
	}

	@SuppressWarnings("unchecked")
	public static <T> T[] toArray(Collection<T> collection) {
		if(collection!=null) {
			return (T[]) collection.toArray();
		}
		return null;
	}

	public static boolean isEmpty(Collection<?> collection) {
		return collection==null || collection.isEmpty();
	}
	
	public static boolean isNotEmpty(Collection<?> collection) {
		return collection!=null && !collection.isEmpty();
	}
	

}
