commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1126183 - /incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/IntHashMap.java
Date Sun, 22 May 2011 19:22:28 GMT
Author: simonetripodi
Date: Sun May 22 19:22:28 2011
New Revision: 1126183

URL: http://svn.apache.org/viewvc?rev=1126183&view=rev
Log:
added IntHashMapIterator raw type

Modified:
    incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/IntHashMap.java

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/IntHashMap.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/IntHashMap.java?rev=1126183&r1=1126182&r2=1126183&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/IntHashMap.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/IntHashMap.java Sun May 22
19:22:28 2011
@@ -60,8 +60,8 @@ public class IntHashMap<K extends Number
      * =================================================================== Private static
classes
      * ===================================================================
      */
-    private class IntHashMapIterator
-        implements Iterator
+    private class IntHashMapIterator<T>
+        implements Iterator<T>
     {
         boolean keys;
 
@@ -99,7 +99,7 @@ public class IntHashMap<K extends Number
             return false;
         }
 
-        public Object next()
+        public T next()
         {
             if ( entry == null )
             {
@@ -113,7 +113,9 @@ public class IntHashMap<K extends Number
                 Entry e = entry;
 
                 entry = e.getNext();
-                return keys ? Integer.valueOf( e.getKey() ) : e.getValue();
+                @SuppressWarnings( "unchecked" ) // used internally, will return only K or
V
+                T returned = (T) ( keys ? Integer.valueOf( e.getKey() ) : e.getValue() );
+                return returned;
             }
             throw new NoSuchElementException( "IntHashMapIterator" );
         }
@@ -448,7 +450,7 @@ public class IntHashMap<K extends Number
     {
         Set<K> result = new HashSet<K>();
 
-        for ( Iterator<K> it = new IntHashMapIterator( table, true ); it.hasNext();
)
+        for ( Iterator<K> it = new IntHashMapIterator<K>( table, true ); it.hasNext();
)
         {
             result.add( it.next() );
         }
@@ -462,7 +464,7 @@ public class IntHashMap<K extends Number
     {
         List<V> result = new ArrayList<V>();
 
-        for ( Iterator<V> it = new IntHashMapIterator( table, false ); it.hasNext();
)
+        for ( Iterator<V> it = new IntHashMapIterator<V>( table, false ); it.hasNext();
)
         {
             result.add( it.next() );
         }



Mime
View raw message