diff base/src/java/util/AbstractMap.d @ 99:5d5bd660917f

build some databind snippets
author Frank Benoit <benoit@tionex.de>
date Wed, 22 Apr 2009 18:59:26 +0200
parents 48d4ee626868
children
line wrap: on
line diff
--- a/base/src/java/util/AbstractMap.d	Wed Apr 22 07:30:21 2009 +0200
+++ b/base/src/java/util/AbstractMap.d	Wed Apr 22 18:59:26 2009 +0200
@@ -90,5 +90,24 @@
         implMissing( __FILE__, __LINE__ );
         return null;
     }
-}
+    public int opApply (int delegate(ref Object value) dg){
+        foreach( entry; entrySet() ){
+            auto me = cast(Map.Entry)entry;
+            auto v = me.getValue();
+            int res = dg( v );
+            if( res ) return res;
+        }
+        return 0;
+    }
+    public int opApply (int delegate(ref Object key, ref Object value) dg){
+        foreach( entry; entrySet() ){
+            auto me = cast(Map.Entry)entry;
+            auto k = me.getKey();
+            auto v = me.getValue();
+            int res = dg( k, v );
+            if( res ) return res;
+        }
+        return 0;
+    } 
+ }