001    /*******************************************************************************
002     * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
003     * Thomschke.
004     * 
005     * All Rights Reserved. This program and the accompanying materials
006     * are made available under the terms of the Eclipse Public License v1.0
007     * which accompanies this distribution, and is available at
008     * http://www.eclipse.org/legal/epl-v10.html
009     * 
010     * Contributors:
011     *     Sebastian Thomschke - initial implementation.
012     *******************************************************************************/
013    package net.sf.oval.collection;
014    
015    import gnu.trove.map.hash.THashMap;
016    import gnu.trove.set.hash.THashSet;
017    
018    import java.util.ArrayList;
019    import java.util.List;
020    import java.util.Map;
021    import java.util.Set;
022    
023    /**
024     * @author Sebastian Thomschke
025     */
026    public class CollectionFactoryTroveImpl implements CollectionFactory
027    {
028            /**
029             * {@inheritDoc}
030             */
031            public <ValueType> List<ValueType> createList()
032            {
033                    return new ArrayList<ValueType>();
034            }
035    
036            /**
037             * {@inheritDoc}
038             */
039            public <ValueType> List<ValueType> createList(final int initialCapacity)
040            {
041                    return new ArrayList<ValueType>(initialCapacity);
042            }
043    
044            /**
045             * {@inheritDoc}
046             */
047            public <KeyType, ValueType> Map<KeyType, ValueType> createMap()
048            {
049                    return new THashMap<KeyType, ValueType>();
050            }
051    
052            /**
053             * {@inheritDoc}
054             */
055            public <KeyType, ValueType> Map<KeyType, ValueType> createMap(final int initialCapacity)
056            {
057                    return new THashMap<KeyType, ValueType>(initialCapacity);
058            }
059    
060            /**
061             * {@inheritDoc}
062             */
063            public <ValueType> Set<ValueType> createSet()
064            {
065                    return new THashSet<ValueType>();
066            }
067    
068            /**
069             * {@inheritDoc}
070             */
071            public <ValueType> Set<ValueType> createSet(final int initialCapacity)
072            {
073                    return new THashSet<ValueType>(initialCapacity);
074            }
075    }