Mercurial > projects > dwt-addons
comparison dwtx/dwtxhelper/Collection.d @ 180:41471f9968be
Collection impl
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 21 Sep 2008 17:18:08 +0200 |
parents | 9008cb2f47c5 |
children | 26589d623405 |
comparison
equal
deleted
inserted
replaced
179:9008cb2f47c5 | 180:41471f9968be |
---|---|
973 } | 973 } |
974 public int size(){ | 974 public int size(){ |
975 return set.size(); | 975 return set.size(); |
976 } | 976 } |
977 public Object[] toArray(){ | 977 public Object[] toArray(){ |
978 implMissing( __FILE__, __LINE__ ); | 978 Object[] res; |
979 return null; | 979 res.length = size(); |
980 int idx = 0; | |
981 foreach( o; set ){ | |
982 res[idx] = o; | |
983 idx++; | |
984 } | |
985 return res; | |
980 } | 986 } |
981 public Object[] toArray(Object[] a){ | 987 public Object[] toArray(Object[] a){ |
982 implMissing( __FILE__, __LINE__ ); | 988 implMissing( __FILE__, __LINE__ ); |
983 return null; | 989 return null; |
984 } | 990 } |
2441 Object[] data = list.toArray(); | 2447 Object[] data = list.toArray(); |
2442 for( int idx = 0; idx < data.length; idx++ ){ | 2448 for( int idx = 0; idx < data.length; idx++ ){ |
2443 list.set( data.length -1 -idx, data[idx] ); | 2449 list.set( data.length -1 -idx, data[idx] ); |
2444 } | 2450 } |
2445 } | 2451 } |
2452 static class LocalEnumeration : Enumeration { | |
2453 Object[] data; | |
2454 this( Object[] data ){ | |
2455 this.data = data; | |
2456 } | |
2457 public bool hasMoreElements(){ | |
2458 return data.length > 0; | |
2459 } | |
2460 public Object nextElement(){ | |
2461 Object res = data[0]; | |
2462 data = data[ 1 .. $ ]; | |
2463 return res; | |
2464 } | |
2465 } | |
2446 static Enumeration enumeration(Collection c){ | 2466 static Enumeration enumeration(Collection c){ |
2447 implMissing( __FILE__, __LINE__ ); | 2467 return new LocalEnumeration( c.toArray() ); |
2448 return null; | |
2449 } | 2468 } |
2450 } | 2469 } |
2451 | 2470 |
2452 class LinkedHashMap : HashMap { | 2471 class LinkedHashMap : HashMap { |
2453 this(){ | 2472 this(){ |