Mercurial > projects > dwt-addons
diff dwtx/dwtxhelper/Collection.d @ 174:c6d7b1ea700b
First sample running
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 11 Sep 2008 00:32:24 +0200 |
parents | d994a8b2cdf7 |
children | 21c77bcb7887 |
line wrap: on
line diff
--- a/dwtx/dwtxhelper/Collection.d Wed Sep 10 23:17:25 2008 +0200 +++ b/dwtx/dwtxhelper/Collection.d Thu Sep 11 00:32:24 2008 +0200 @@ -1921,8 +1921,9 @@ data.length = size; data.length = 0; } - this(Collection){ - implMissing( __FILE__, __LINE__ ); + this(Collection col){ + this(cast(int)(col.size*1.1)); + addAll(col); } void add(int index, Object element){ data.length = data.length +1; @@ -1937,8 +1938,13 @@ return add(stringcast(o)); } bool addAll(Collection c){ - implMissing( __FILE__, __LINE__ ); - return false; + if( c.size() is 0 ) return false; + uint idx = data.length; + data.length = data.length + c.size(); + foreach( o; c ){ + data[ idx++ ] = o; + } + return true; } bool addAll(int index, Collection c){ implMissing( __FILE__, __LINE__ ); @@ -2113,7 +2119,10 @@ // only for D public int opApply (int delegate(ref Object value) dg){ - implMissing( __FILE__, __LINE__ ); + foreach( o; data ){ + auto res = dg( o ); + if( res ) return res; + } return 0; } }