You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/08/24 17:30:55 UTC

svn commit: r807283 - in /incubator/pivot/trunk: core/src/org/apache/pivot/collections/ core/src/org/apache/pivot/collections/adapter/ core/src/org/apache/pivot/collections/concurrent/ core/src/org/apache/pivot/collections/immutable/ core/test/org/apac...

Author: gbrown
Date: Mon Aug 24 15:30:54 2009
New Revision: 807283

URL: http://svn.apache.org/viewvc?rev=807283&view=rev
Log:
Rename Map#count() to getCount(); eliminate "weak" constructor argument.


Modified:
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/Map.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/MapList.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java
    incubator/pivot/trunk/core/test/org/apache/pivot/collections/test/HashMapTest.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java Mon Aug 24 15:30:54 2009
@@ -66,8 +66,10 @@
     private Comparator<T> comparator = null;
     private transient ListListenerList<T> listListeners = new ListListenerList<T>();
 
+    public static final int DEFAULT_CAPACITY = 10;
+
     public ArrayList() {
-        items = new Object[10];
+        items = new Object[DEFAULT_CAPACITY];
     }
 
     public ArrayList(Comparator<T> comparator) {

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/EnumMap.java Mon Aug 24 15:30:54 2009
@@ -105,7 +105,7 @@
         return keySet.isEmpty();
     }
 
-    public int count() {
+    public int getCount() {
         return keySet.count();
     }
 

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashMap.java Mon Aug 24 15:30:54 2009
@@ -40,19 +40,11 @@
     private transient MapListenerList<K, V> mapListeners = new MapListenerList<K, V>();
 
     public HashMap() {
-        this(false, null);
-    }
-
-    public HashMap(boolean weak) {
-        this(weak, null);
-    }
-
-    public HashMap(Map<K, V> map) {
-        this(false, map);
+        hashMap = new java.util.HashMap<K, V>();
     }
 
     public HashMap(Pair<K, V>... pairs) {
-        this(false);
+        this();
 
         for (int i = 0; i < pairs.length; i++) {
             Pair<K, V> pair = pairs[i];
@@ -60,8 +52,8 @@
         }
     }
 
-    public HashMap(boolean weak, Map<K, V> map) {
-        hashMap = (weak) ? new java.util.WeakHashMap<K, V>() : new java.util.HashMap<K, V>();
+    public HashMap(Map<K, V> map) {
+        this();
 
         if (map != null) {
             for (K key : map) {
@@ -121,7 +113,7 @@
         return hashMap.isEmpty();
     }
 
-    public int count() {
+    public int getCount() {
         return hashMap.size();
     }
 

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/HashSet.java Mon Aug 24 15:30:54 2009
@@ -95,7 +95,7 @@
     }
 
     public int count() {
-        return hashMap.count();
+        return hashMap.getCount();
     }
 
     public Comparator<E> getComparator() {

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/Map.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/Map.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/Map.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/Map.java Mon Aug 24 15:30:54 2009
@@ -133,7 +133,7 @@
     /**
      * Returns the number of entries in the map.
      */
-    public int count();
+    public int getCount();
 
     /**
      * @see MapListener#comparatorChanged(Map, Comparator)

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/MapList.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/MapList.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/MapList.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/MapList.java Mon Aug 24 15:30:54 2009
@@ -169,7 +169,7 @@
             mapListListeners.sourceChanged(this, previousSource);
 
             // Refresh the view
-            view = new ArrayList<Pair<K, V>>(source.count());
+            view = new ArrayList<Pair<K, V>>(source.getCount());
 
             for (K key : source) {
                 listListeners.itemInserted(this, view.add(new Pair<K, V>(key, source.get(key))));

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/adapter/MapAdapter.java Mon Aug 24 15:30:54 2009
@@ -93,7 +93,7 @@
         return map.isEmpty();
     }
 
-    public int count() {
+    public int getCount() {
         return map.size();
     }
 

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/concurrent/SynchronizedMap.java Mon Aug 24 15:30:54 2009
@@ -115,8 +115,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    public synchronized int count() {
-        return ((Map<K, V>)collection).count();
+    public synchronized int getCount() {
+        return ((Map<K, V>)collection).getCount();
     }
 
     public ListenerList<MapListener<K, V>> getMapListeners() {

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/immutable/ImmutableMap.java Mon Aug 24 15:30:54 2009
@@ -66,8 +66,8 @@
         return map.isEmpty();
     }
 
-    public int count() {
-        return map.count();
+    public int getCount() {
+        return map.getCount();
     }
 
     public Comparator<K> getComparator() {

Modified: incubator/pivot/trunk/core/test/org/apache/pivot/collections/test/HashMapTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/test/org/apache/pivot/collections/test/HashMapTest.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/core/test/org/apache/pivot/collections/test/HashMapTest.java (original)
+++ incubator/pivot/trunk/core/test/org/apache/pivot/collections/test/HashMapTest.java Mon Aug 24 15:30:54 2009
@@ -39,7 +39,7 @@
         HashMap<String, Integer> map = new HashMap<String, Integer>();
 
         assertTrue(map.isEmpty());
-        assertEquals(0, map.count());
+        assertEquals(0, map.getCount());
         assertNull(map.getComparator());
         assertFalse(map.containsKey("a"));
         assertNotNull(map.getMapListeners());
@@ -51,11 +51,11 @@
 
         assertEquals(2, (int)map.get("a"));
 
-        assertEquals(1, map.count());
+        assertEquals(1, map.getCount());
 
         assertEquals(2, (int)map.remove("a"));
 
-        assertEquals(0, map.count());
+        assertEquals(0, map.getCount());
 
         map.put("a", 1);
         map.put("b", 2);
@@ -65,7 +65,7 @@
         assertEquals(2, (int)map.get("b"));
         assertEquals(3, (int)map.get("c"));
 
-        assertEquals(3, map.count());
+        assertEquals(3, map.getCount());
 
         Iterator<String> iter = map.iterator();
         int count = 0;
@@ -88,7 +88,7 @@
 
         map.clear();
 
-        assertEquals(0, map.count());
+        assertEquals(0, map.getCount());
 
         assertEquals(null, map.get("a"));
         assertEquals(null, map.get("b"));
@@ -102,13 +102,13 @@
         HashMap<String, Integer> map = new HashMap<String, Integer>(
                 new Map.Pair<String, Integer>("a", 1),
                 new Map.Pair<String, Integer>("b", 2));
-        assertEquals(2, map.count());
+        assertEquals(2, map.getCount());
 
-        map = new HashMap<String, Integer>(true, map);
-        assertEquals(2, map.count());
+        map = new HashMap<String, Integer>(map);
+        assertEquals(2, map.getCount());
 
         map = new HashMap<String, Integer>(map);
-        assertEquals(2, map.count());
+        assertEquals(2, map.getCount());
 
     }
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java?rev=807283&r1=807282&r2=807283&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java Mon Aug 24 15:30:54 2009
@@ -126,7 +126,7 @@
         }
 
         public int size() {
-            return namedObjects.count();
+            return namedObjects.getCount();
         }
 
         public Collection<Object> values() {