svn commit: r672700 - in /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections: OrderedMap.java OrderedSet.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r672700 - in /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections: OrderedMap.java OrderedSet.java

doogie-3
Author: doogie
Date: Sun Jun 29 21:32:58 2008
New Revision: 672700

URL: http://svn.apache.org/viewvc?rev=672700&view=rev
Log:
Generied.

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedMap.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedSet.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedMap.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedMap.java?rev=672700&r1=672699&r2=672700&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedMap.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedMap.java Sun Jun 29 21:32:58 2008
@@ -23,37 +23,39 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
+import javolution.util.FastList;
 /**
  * @deprecated
  * OrderedMap - HashMap backed by a linked list.
  *
  */
-public class OrderedMap extends HashMap {
+public class OrderedMap<K, V> extends HashMap<K, V> {
 
-    private List orderedKeys = new LinkedList();
+    private List<K> orderedKeys = FastList.newInstance();
 
     /**
      * @see java.util.Map#keySet()
      */  
-    public Set keySet() {
-        return new LinkedHashSet(orderedKeys);
+    public Set<K> keySet() {
+        return new LinkedHashSet<K>(orderedKeys);
     }
 
     /**
      * @return List a copy of the ordered keys list which backs this map
      */
-    public List getOrderedKeys() {
-        return new LinkedList(this.orderedKeys);
+    public List<K> getOrderedKeys() {
+        List<K> keys = FastList.newInstance();
+        keys.addAll(this.orderedKeys);
+        return keys;
     }
 
     /**
      * @see java.util.Map#put(java.lang.Object, java.lang.Object)
      */
-    public Object put(Object key, Object value) {
+    public V put(K key, V value) {
         if (!orderedKeys.contains(key))
             orderedKeys.add(key);
         return super.put(key, value);
@@ -70,7 +72,7 @@
     /**
      * @see java.util.Map#remove(java.lang.Object)
      */
-    public Object remove(Object key) {
+    public V remove(Object key) {
         if (orderedKeys.contains(key))
             orderedKeys.remove(key);
         return super.remove(key);
@@ -79,17 +81,16 @@
     /**
      * @see java.util.Map#values()
      */
-    public Collection values() {
-        Iterator i = orderedKeys.iterator();
-        if (!i.hasNext()) {
+    public Collection<V> values() {
+        if (orderedKeys.isEmpty()) {
             return null;
         }
         
-        List values = new ArrayList();        
-        while (i.hasNext()) {
-            values.add(this.get(i.next()));
+        List<V> values = FastList.newInstance();
+        for (K key: orderedKeys) {
+            values.add(this.get(key));
         }
-        return (Collection) values;
+        return values;
     }
 
     public int indexOf(Object key) {

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedSet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedSet.java?rev=672700&r1=672699&r2=672700&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedSet.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/OrderedSet.java Sun Jun 29 21:32:58 2008
@@ -29,10 +29,10 @@
  * OrderedSet - Set interface wrapper around a LinkedList
  *
  */
-public class OrderedSet extends AbstractSet {
+public class OrderedSet<V> extends AbstractSet<V> {
 
     // This set's back LinkedList
-    private List backedList = new LinkedList();
+    private List<V> backedList = new LinkedList<V>();
 
     /**
      * Constructs a set containing the elements of the specified
@@ -48,17 +48,14 @@
      *
      * @param c the collection whose elements are to be placed into this set.
      */
-    public OrderedSet(Collection c) {
-        Iterator i = c.iterator();
-
-        while (i.hasNext())
-            add(i.next());
+    public OrderedSet(Collection<? extends V> c) {
+        addAll(c);
     }
 
     /**
      * @see java.util.Collection#iterator()
      */  
-    public Iterator iterator() {
+    public Iterator<V> iterator() {
         return backedList.iterator();
     }
 
@@ -72,7 +69,7 @@
     /**
      * @see java.util.Collection#add(java.lang.Object)
      */
-    public boolean add(Object obj) {
+    public boolean add(V obj) {
         int index = backedList.indexOf(obj);
 
         if (index == -1)