Mercurial > projects > dwt-addons
changeset 180:41471f9968be
Collection impl
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 21 Sep 2008 17:18:08 +0200 |
parents | 9008cb2f47c5 |
children | 8116a58394c3 |
files | dwtx/dwtxhelper/Collection.d |
diffstat | 1 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtx/dwtxhelper/Collection.d Fri Sep 19 22:37:04 2008 +0200 +++ b/dwtx/dwtxhelper/Collection.d Sun Sep 21 17:18:08 2008 +0200 @@ -975,8 +975,14 @@ return set.size(); } public Object[] toArray(){ - implMissing( __FILE__, __LINE__ ); - return null; + Object[] res; + res.length = size(); + int idx = 0; + foreach( o; set ){ + res[idx] = o; + idx++; + } + return res; } public Object[] toArray(Object[] a){ implMissing( __FILE__, __LINE__ ); @@ -2443,9 +2449,22 @@ list.set( data.length -1 -idx, data[idx] ); } } + static class LocalEnumeration : Enumeration { + Object[] data; + this( Object[] data ){ + this.data = data; + } + public bool hasMoreElements(){ + return data.length > 0; + } + public Object nextElement(){ + Object res = data[0]; + data = data[ 1 .. $ ]; + return res; + } + } static Enumeration enumeration(Collection c){ - implMissing( __FILE__, __LINE__ ); - return null; + return new LocalEnumeration( c.toArray() ); } }