Mercurial > projects > dwt-addons
comparison dwtx/dwtxhelper/Collection.d @ 198:489eb3f36068
Add impl for Collection
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 19 Feb 2009 17:21:08 +0100 |
parents | a4d38d47ddc4 |
children | eb98a5cbfd78 |
comparison
equal
deleted
inserted
replaced
197:0ea0c9f9008f | 198:489eb3f36068 |
---|---|
2492 | 2492 |
2493 static Collection synchronizedCollection(Collection c){ | 2493 static Collection synchronizedCollection(Collection c){ |
2494 implMissing( __FILE__, __LINE__ ); | 2494 implMissing( __FILE__, __LINE__ ); |
2495 return null; | 2495 return null; |
2496 } | 2496 } |
2497 static class SynchronizedList : List { | |
2498 private List list; | |
2499 private this( List list ){ this.list = list; } | |
2500 // Collection | |
2501 public int opApply (int delegate(ref Object value) dg){ synchronized{ return this.list.opApply(dg); } } | |
2502 // List | |
2503 public void add(int index, Object element){ synchronized{ return this.list.add(index, element); } } | |
2504 public bool add(Object o){ synchronized{ return this.list.add(o); } } | |
2505 public bool add(String o){ synchronized{ return this.list.add(o); } } | |
2506 public bool addAll(Collection c){ synchronized{ return this.list.addAll(c); } } | |
2507 public bool addAll(int index, Collection c){ synchronized{ return this.list.addAll(index, c); } } | |
2508 public void clear(){ synchronized{ return this.list.clear(); } } | |
2509 public bool contains(Object o){ synchronized{ return this.list.contains(o); } } | |
2510 public bool contains(String o){ synchronized{ return this.list.contains(o); } } | |
2511 public bool containsAll(Collection c){ synchronized{ return this.list.containsAll(c); } } | |
2512 public int opEquals(Object o){ synchronized{ return this.list.opEquals(o); } } | |
2513 public Object get(int index){ synchronized{ return this.list.get(index); } } | |
2514 public hash_t toHash(){ synchronized{ return this.list.toHash(); } } | |
2515 public int indexOf(Object o){ synchronized{ return this.list.indexOf(o); } } | |
2516 public bool isEmpty(){ synchronized{ return this.list.isEmpty(); } } | |
2517 public Iterator iterator(){ synchronized{ return this.list.iterator(); } } | |
2518 public int lastIndexOf(Object o){ synchronized{ return this.list.lastIndexOf(o); } } | |
2519 public ListIterator listIterator(){ synchronized{ return this.list.listIterator(); } } | |
2520 public ListIterator listIterator(int index){ synchronized{ return this.list.listIterator(index); } } | |
2521 public Object remove(int index){ synchronized{ return this.list.remove(index); } } | |
2522 public bool remove(Object o){ synchronized{ return this.list.remove(o); } } | |
2523 public bool remove(String o){ synchronized{ return this.list.remove(o); } } | |
2524 public bool removeAll(Collection c){ synchronized{ return this.list.removeAll(c); } } | |
2525 public bool retainAll(Collection c){ synchronized{ return this.list.retainAll(c); } } | |
2526 public Object set(int index, Object element){ synchronized{ return this.list.set(index,element); } } | |
2527 public int size(){ synchronized{ return this.list.size(); } } | |
2528 public List subList(int fromIndex, int toIndex){ synchronized{ return this.list.subList(fromIndex,toIndex); } } | |
2529 public Object[] toArray(){ synchronized{ return this.list.toArray(); } } | |
2530 public Object[] toArray(Object[] a){ synchronized{ return this.list.toArray(a); } } | |
2531 } | |
2497 static List synchronizedList(List list){ | 2532 static List synchronizedList(List list){ |
2498 implMissing( __FILE__, __LINE__ ); | 2533 return new SynchronizedList(list); |
2499 return null; | 2534 } |
2535 | |
2536 static class SynchronizedMap : Map { | |
2537 private Map map; | |
2538 //interface Entry { | |
2539 // int opEquals(Object o); | |
2540 // Object getKey(); | |
2541 // Object getValue(); | |
2542 // hash_t toHash(); | |
2543 // Object setValue(Object value); | |
2544 //} | |
2545 private this( Map map ){ | |
2546 this.map = map; | |
2547 } | |
2548 public void clear(){ synchronized{ this.map.clear(); } } | |
2549 public bool containsKey(Object key){ synchronized{ return this.map.containsKey(key); } } | |
2550 public bool containsKey(String key){ synchronized{ return this.map.containsKey(key); } } | |
2551 public bool containsValue(Object value){ synchronized{ return this.map.containsValue(value); } } | |
2552 public Set entrySet(){ synchronized{ return this.map.entrySet(); } } | |
2553 public int opEquals(Object o){ synchronized{ return this.map.opEquals(o); } } | |
2554 public Object get(Object key){ synchronized{ return this.map.get(key); } } | |
2555 public Object get(String key){ synchronized{ return this.map.get(key); } } | |
2556 public hash_t toHash(){ synchronized{ return this.map.toHash(); } } | |
2557 public bool isEmpty(){ synchronized{ return this.map.isEmpty(); } } | |
2558 public Set keySet(){ synchronized{ return this.map.keySet(); } } | |
2559 public Object put(Object key, Object value){ synchronized{ return this.map.put(key,value); } } | |
2560 public Object put(String key, Object value){ synchronized{ return this.map.put(key,value); } } | |
2561 public Object put(Object key, String value){ synchronized{ return this.map.put(key,value); } } | |
2562 public Object put(String key, String value){ synchronized{ return this.map.put(key,value); } } | |
2563 public void putAll(Map t){ synchronized{ return this.map.putAll(t); } } | |
2564 public Object remove(Object key){ synchronized{ return this.map.remove(key); } } | |
2565 public Object remove(String key){ synchronized{ return this.map.remove(key); } } | |
2566 public int size(){ synchronized{ return this.map.size(); } } | |
2567 public Collection values(){ synchronized{ return this.map.values(); } } | |
2568 | |
2569 // only for D | |
2570 public int opApply (int delegate(ref Object value) dg){ synchronized{ return this.map.opApply( dg ); } } | |
2571 public int opApply (int delegate(ref Object key, ref Object value) dg){ synchronized{ return this.map.opApply( dg ); } } | |
2500 } | 2572 } |
2501 static Map synchronizedMap(Map m){ | 2573 static Map synchronizedMap(Map m){ |
2502 implMissing( __FILE__, __LINE__ ); | 2574 return new SynchronizedMap(m); |
2503 return null; | |
2504 } | 2575 } |
2505 static Set synchronizedSet(Set s){ | 2576 static Set synchronizedSet(Set s){ |
2506 implMissing( __FILE__, __LINE__ ); | 2577 implMissing( __FILE__, __LINE__ ); |
2507 return null; | 2578 return null; |
2508 } | 2579 } |