View Javadoc
1   /*******************************************************************************
2    * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
3    * Thomschke.
4    * 
5    * All Rights Reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    * http://www.eclipse.org/legal/epl-v10.html
9    * 
10   * Contributors:
11   *     Sebastian Thomschke - initial implementation.
12   *******************************************************************************/
13  package net.sf.oval.collection;
14  
15  import gnu.trove.map.hash.THashMap;
16  import gnu.trove.set.hash.THashSet;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Map;
21  import java.util.Set;
22  
23  /**
24   * @author Sebastian Thomschke
25   */
26  public class CollectionFactoryTroveImpl implements CollectionFactory
27  {
28  	/**
29  	 * {@inheritDoc}
30  	 */
31  	public <ValueType> List<ValueType> createList()
32  	{
33  		return new ArrayList<ValueType>();
34  	}
35  
36  	/**
37  	 * {@inheritDoc}
38  	 */
39  	public <ValueType> List<ValueType> createList(final int initialCapacity)
40  	{
41  		return new ArrayList<ValueType>(initialCapacity);
42  	}
43  
44  	/**
45  	 * {@inheritDoc}
46  	 */
47  	public <KeyType, ValueType> Map<KeyType, ValueType> createMap()
48  	{
49  		return new THashMap<KeyType, ValueType>();
50  	}
51  
52  	/**
53  	 * {@inheritDoc}
54  	 */
55  	public <KeyType, ValueType> Map<KeyType, ValueType> createMap(final int initialCapacity)
56  	{
57  		return new THashMap<KeyType, ValueType>(initialCapacity);
58  	}
59  
60  	/**
61  	 * {@inheritDoc}
62  	 */
63  	public <ValueType> Set<ValueType> createSet()
64  	{
65  		return new THashSet<ValueType>();
66  	}
67  
68  	/**
69  	 * {@inheritDoc}
70  	 */
71  	public <ValueType> Set<ValueType> createSet(final int initialCapacity)
72  	{
73  		return new THashSet<ValueType>(initialCapacity);
74  	}
75  }