diff options
author | Sven Gothel <sgothel@jausoft.com> | 2013-04-01 02:45:40 +0200 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2013-04-01 02:45:40 +0200 |
commit | bdbba7ca4ae73c3212a46318dab83731706c4e3e (patch) | |
tree | e2bd83ef7d6c6fefcc4b18bf8108c0a852782a53 /src/java/com | |
parent | a256b64fa57d9f7789baaf379bd9afdc54d8095d (diff) |
ArrayHashSet: Add ctor w/ initialCapacity and (initialCapacity, loadFactor)
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/jogamp/common/util/ArrayHashSet.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java index 5d6d3c8..0f5f65b 100644 --- a/src/java/com/jogamp/common/util/ArrayHashSet.java +++ b/src/java/com/jogamp/common/util/ArrayHashSet.java @@ -68,13 +68,24 @@ import java.util.ListIterator; public class ArrayHashSet<E> implements Cloneable, Collection<E>, List<E> { - HashMap<E,E> map = new HashMap<E,E>(); // object -> object - ArrayList<E> data = new ArrayList<E>(); // list of objects + private final HashMap<E,E> map; // object -> object + private final ArrayList<E> data; // list of objects public ArrayHashSet() { - clear(); + map = new HashMap<E,E>(); + data = new ArrayList<E>(); } + public ArrayHashSet(int initialCapacity) { + map = new HashMap<E,E>(initialCapacity); + data = new ArrayList<E>(initialCapacity); + } + + public ArrayHashSet(int initialCapacity, float loadFactor) { + map = new HashMap<E,E>(initialCapacity, loadFactor); + data = new ArrayList<E>(initialCapacity); + } + // // Cloneable // @@ -83,6 +94,7 @@ public class ArrayHashSet<E> * @return a shallow copy of this ArrayHashSet, elements are not copied. */ public final Object clone() { + @SuppressWarnings("unchecked") ArrayList<E> clonedList = (ArrayList<E>)data.clone(); ArrayHashSet<E> newObj = new ArrayHashSet<E>(); @@ -90,7 +102,14 @@ public class ArrayHashSet<E> return newObj; } - + + /** Returns this object ordered ArrayList. Use w/ care, it's not a copy. */ + public final ArrayList<E> getData() { return data; } + /** Returns this object hash map. Use w/ care, it's not a copy. */ + public final HashMap<E,E> getMap() { return map; } + + public final String toString() { return data.toString(); } + // // Collection // @@ -356,6 +375,7 @@ public class ArrayHashSet<E> /** * @return a shallow copy of this ArrayHashSet's ArrayList, elements are not copied. */ + @SuppressWarnings("unchecked") public final ArrayList<E> toArrayList() { return (ArrayList<E>) data.clone(); } |