changeset 292:695802b523c0

Adjustements for the container rework in dwt-addons
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 15:02:44 +0200
parents 75cb516e281e
children 3dfa75c74ed2
files dwt/dwthelper/WeakHashMap.d dwt/dwthelper/utils.d
diffstat 2 files changed, 31 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dwthelper/WeakHashMap.d	Tue Aug 05 01:15:34 2008 +0200
+++ b/dwt/dwthelper/WeakHashMap.d	Thu Aug 07 15:02:44 2008 +0200
@@ -46,12 +46,12 @@
         gcLock = ClassInfo.find( "gcx.GCLock" );
     }
 
-    public void add (Object key, Object element){
+    public void put (Object key, Object element){
         auto k = new Ref(key);
         rt_attachDisposeEvent(key, &unhook);
         data[ k ] = element;
     }
-    public void removeKey (Object key){
+    public void remove (Object key){
         scope k = new Ref(key);
         if( auto p = k in data ){
             data.remove( k );
--- a/dwt/dwthelper/utils.d	Tue Aug 05 01:15:34 2008 +0200
+++ b/dwt/dwthelper/utils.d	Thu Aug 07 15:02:44 2008 +0200
@@ -845,12 +845,6 @@
     }
 }
 
-interface Enumeration {
-    public bool hasMoreElements();
-    public Object nextElement();
-}
-
-
 template arraycast(T) {
     T[] arraycast(U) (U[] u) {
         static if (
@@ -894,6 +888,35 @@
     return res;
 }
 
+String[] stringArrayFromObject( Object obj ){
+    if( auto wrapper = cast(ArrayWrapperString2)obj ){
+        return wrapper.array;
+    }
+    if( auto wrapper = cast(ArrayWrapperObject)obj ){
+        String[] res = new String[ wrapper.array.length ];
+        foreach( idx, o; wrapper.array ){
+            if( auto swrapper = cast(ArrayWrapperString) o ){
+                res[idx] = swrapper.array;
+            }
+        }
+        return res;
+    }
+    assert( obj is null ); // if not null, it was the wrong type
+    return null;
+}
+
+T[] arrayFromObject(T)( Object obj ){
+    if( auto wrapper = cast(ArrayWrapperObject)obj ){
+        T[] res = new T[ wrapper.array.length ];
+        foreach( idx, o; wrapper.array ){
+            res[idx] = cast(T)o;
+        }
+        return res;
+    }
+    assert( obj is null ); // if not null, it was the wrong type
+    return null;
+}
+
 
 bool ArrayEquals(T)( T[] a, T[] b ){
     if( a.length !is b.length ){
@@ -921,24 +944,6 @@
     return true;
 }
 
-class Arrays{
-    public static bool equals(Object[] a, Object[] b){
-        if( a.length !is b.length ){
-            return false;
-        }
-        for( int i = 0; i < a.length; i++ ){
-            if( a[i] is null && b[i] is null ){
-                continue;
-            }
-            if( a[i] !is null && b[i] !is null && a[i] == b[i] ){
-                continue;
-            }
-            return false;
-        }
-        return true;
-    }
-}
-
 int SeqIndexOf(T)( tango.util.collection.model.Seq.Seq!(T) s, T src ){
     int idx;
     foreach( e; s ){