From bdbba7ca4ae73c3212a46318dab83731706c4e3e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 1 Apr 2013 02:45:40 +0200 Subject: ArrayHashSet: Add ctor w/ initialCapacity and (initialCapacity, loadFactor) --- src/java/com/jogamp/common/util/ArrayHashSet.java | 28 +++++++++++++++++++---- 1 file 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 implements Cloneable, Collection, List { - HashMap map = new HashMap(); // object -> object - ArrayList data = new ArrayList(); // list of objects + private final HashMap map; // object -> object + private final ArrayList data; // list of objects public ArrayHashSet() { - clear(); + map = new HashMap(); + data = new ArrayList(); } + public ArrayHashSet(int initialCapacity) { + map = new HashMap(initialCapacity); + data = new ArrayList(initialCapacity); + } + + public ArrayHashSet(int initialCapacity, float loadFactor) { + map = new HashMap(initialCapacity, loadFactor); + data = new ArrayList(initialCapacity); + } + // // Cloneable // @@ -83,6 +94,7 @@ public class ArrayHashSet * @return a shallow copy of this ArrayHashSet, elements are not copied. */ public final Object clone() { + @SuppressWarnings("unchecked") ArrayList clonedList = (ArrayList)data.clone(); ArrayHashSet newObj = new ArrayHashSet(); @@ -90,7 +102,14 @@ public class ArrayHashSet return newObj; } - + + /** Returns this object ordered ArrayList. Use w/ care, it's not a copy. */ + public final ArrayList getData() { return data; } + /** Returns this object hash map. Use w/ care, it's not a copy. */ + public final HashMap getMap() { return map; } + + public final String toString() { return data.toString(); } + // // Collection // @@ -356,6 +375,7 @@ public class ArrayHashSet /** * @return a shallow copy of this ArrayHashSet's ArrayList, elements are not copied. */ + @SuppressWarnings("unchecked") public final ArrayList toArrayList() { return (ArrayList) data.clone(); } -- cgit v1.2.3