changeset 106:8ab6fb387666

more Collection impl
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 16:03:56 +0200
parents 2be5f40557e6
children ffa785dc65e5 a26bb7394581
files dwtx/dwtxhelper/Collection.d
diffstat 1 files changed, 25 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/dwtx/dwtxhelper/Collection.d	Thu Aug 07 16:03:20 2008 +0200
+++ b/dwtx/dwtxhelper/Collection.d	Thu Aug 07 16:03:56 2008 +0200
@@ -1976,13 +1976,27 @@
         }
         return EMPTY_LIST_;
     }
+    private static Map EMPTY_MAP_;
     public static Map EMPTY_MAP(){
-        implMissing( __FILE__, __LINE__ );
-        return null;
+        if( EMPTY_MAP_ is null ){
+            synchronized(Collections.classinfo ){
+                if( EMPTY_MAP_ is null ){
+                    EMPTY_MAP_ = new TreeMap();
+                }
+            }
+        }
+        return EMPTY_MAP_;
     }
+    private static Set EMPTY_SET_;
     public static Set EMPTY_SET(){
-        implMissing( __FILE__, __LINE__ );
-        return null;
+        if( EMPTY_SET_ is null ){
+            synchronized(Collections.classinfo ){
+                if( EMPTY_SET_ is null ){
+                    EMPTY_SET_ = new TreeSet();
+                }
+            }
+        }
+        return EMPTY_SET_;
     }
 
     public static List unmodifiableList( List list ){
@@ -1998,8 +2012,9 @@
         return null;
     }
     public static Set singleton( Object o ){
-        implMissing( __FILE__, __LINE__ );
-        return null;
+        TreeSet res = new TreeSet();
+        res.add(o);
+        return res;
     }
     public static void     sort(List list){
         implMissing( __FILE__, __LINE__ );
@@ -2033,7 +2048,10 @@
 //         return null;
 //     }
     static void     reverse(List list) {
-        implMissing( __FILE__, __LINE__ );
+        Object[] data = list.toArray();
+        for( int idx = 0; idx < data.length; idx++ ){
+            list.set( data.length -1 -idx, data[idx] );
+        }
     }
     static Enumeration     enumeration(Collection c){
         implMissing( __FILE__, __LINE__ );