changeset 198:489eb3f36068

Add impl for Collection
author Frank Benoit <benoit@tionex.de>
date Thu, 19 Feb 2009 17:21:08 +0100
parents 0ea0c9f9008f
children eb98a5cbfd78
files dwtx/dwtxhelper/Collection.d
diffstat 1 files changed, 75 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dwtx/dwtxhelper/Collection.d	Wed Feb 18 19:35:22 2009 +0100
+++ b/dwtx/dwtxhelper/Collection.d	Thu Feb 19 17:21:08 2009 +0100
@@ -2494,13 +2494,84 @@
         implMissing( __FILE__, __LINE__ );
         return null;
     }
+    static class SynchronizedList : List {
+        private List list;
+        private this( List list ){ this.list = list; }
+        // Collection
+        public int opApply (int delegate(ref Object value) dg){ synchronized{ return this.list.opApply(dg); } }
+        // List
+        public void     add(int index, Object element){ synchronized{ return this.list.add(index, element); } }
+        public bool     add(Object o){ synchronized{ return this.list.add(o); } }
+        public bool     add(String o){ synchronized{ return this.list.add(o); } }
+        public bool     addAll(Collection c){ synchronized{ return this.list.addAll(c); } }
+        public bool     addAll(int index, Collection c){ synchronized{ return this.list.addAll(index, c); } }
+        public void     clear(){ synchronized{ return this.list.clear(); } }
+        public bool     contains(Object o){ synchronized{ return this.list.contains(o); } }
+        public bool     contains(String o){ synchronized{ return this.list.contains(o); } }
+        public bool     containsAll(Collection c){ synchronized{ return this.list.containsAll(c); } }
+        public int      opEquals(Object o){ synchronized{ return this.list.opEquals(o); } }
+        public Object   get(int index){ synchronized{ return this.list.get(index); } }
+        public hash_t   toHash(){ synchronized{ return this.list.toHash(); } }
+        public int      indexOf(Object o){ synchronized{ return this.list.indexOf(o); } }
+        public bool     isEmpty(){ synchronized{ return this.list.isEmpty(); } }
+        public Iterator iterator(){ synchronized{ return this.list.iterator(); } }
+        public int      lastIndexOf(Object o){ synchronized{ return this.list.lastIndexOf(o); } }
+        public ListIterator   listIterator(){ synchronized{ return this.list.listIterator(); } }
+        public ListIterator   listIterator(int index){ synchronized{ return this.list.listIterator(index); } }
+        public Object   remove(int index){ synchronized{ return this.list.remove(index); } }
+        public bool     remove(Object o){ synchronized{ return this.list.remove(o); } }
+        public bool     remove(String o){ synchronized{ return this.list.remove(o); } }
+        public bool     removeAll(Collection c){ synchronized{ return this.list.removeAll(c); } }
+        public bool     retainAll(Collection c){ synchronized{ return this.list.retainAll(c); } }
+        public Object   set(int index, Object element){ synchronized{ return this.list.set(index,element); } }
+        public int      size(){ synchronized{ return this.list.size(); } }
+        public List     subList(int fromIndex, int toIndex){ synchronized{ return this.list.subList(fromIndex,toIndex); } }
+        public Object[] toArray(){ synchronized{ return this.list.toArray(); } }
+        public Object[] toArray(Object[] a){ synchronized{ return this.list.toArray(a); } }
+    }
     static List     synchronizedList(List list){
-        implMissing( __FILE__, __LINE__ );
-        return null;
+        return new SynchronizedList(list);
+    }
+
+    static class SynchronizedMap : Map {
+        private Map map;
+        //interface Entry {
+        //    int   opEquals(Object o);
+        //    Object     getKey();
+        //    Object     getValue();
+        //    hash_t     toHash();
+        //    Object     setValue(Object value);
+        //}
+        private this( Map map ){
+            this.map = map;
+        }
+        public void clear(){ synchronized{ this.map.clear(); } }
+        public bool containsKey(Object key){ synchronized{ return this.map.containsKey(key); } }
+        public bool containsKey(String key){ synchronized{ return this.map.containsKey(key); } }
+        public bool containsValue(Object value){ synchronized{ return this.map.containsValue(value); } }
+        public Set  entrySet(){ synchronized{ return this.map.entrySet(); } }
+        public int opEquals(Object o){ synchronized{ return this.map.opEquals(o); } }
+        public Object get(Object key){ synchronized{ return this.map.get(key); } }
+        public Object get(String key){ synchronized{ return this.map.get(key); } }
+        public hash_t toHash(){ synchronized{ return this.map.toHash(); } }
+        public bool isEmpty(){ synchronized{ return this.map.isEmpty(); } }
+        public Set    keySet(){ synchronized{ return this.map.keySet(); } }
+        public Object put(Object key, Object value){ synchronized{ return this.map.put(key,value); } }
+        public Object put(String key, Object value){ synchronized{ return this.map.put(key,value); } }
+        public Object put(Object key, String value){ synchronized{ return this.map.put(key,value); } }
+        public Object put(String key, String value){ synchronized{ return this.map.put(key,value); } }
+        public void   putAll(Map t){ synchronized{ return this.map.putAll(t); } }
+        public Object remove(Object key){ synchronized{ return this.map.remove(key); } }
+        public Object remove(String key){ synchronized{ return this.map.remove(key); } }
+        public int    size(){ synchronized{ return this.map.size(); } }
+        public Collection values(){ synchronized{ return this.map.values(); } }
+
+        // only for D
+        public int opApply (int delegate(ref Object value) dg){ synchronized{ return this.map.opApply( dg ); } }
+        public int opApply (int delegate(ref Object key, ref Object value) dg){ synchronized{ return this.map.opApply( dg ); } }
     }
     static Map  synchronizedMap(Map m){
-        implMissing( __FILE__, __LINE__ );
-        return null;
+        return new SynchronizedMap(m);
     }
     static Set  synchronizedSet(Set s){
         implMissing( __FILE__, __LINE__ );