Mercurial > projects > dwt-addons
changeset 184:26589d623405
Added ListIterator for ArrayList
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Oct 2008 15:02:28 +0200 |
parents | c36336245fb1 |
children | 987b95661bb9 |
files | dwtx/dwtxhelper/Collection.d |
diffstat | 1 files changed, 46 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtx/dwtxhelper/Collection.d Sat Oct 18 15:01:42 2008 +0200 +++ b/dwtx/dwtxhelper/Collection.d Sat Oct 18 15:02:28 2008 +0200 @@ -2027,15 +2027,15 @@ return data.length is 0; } class LocalIterator : Iterator{ - int idx = 0; + int idx = -1; public this(){ } public bool hasNext(){ - return idx < data.length; + return idx+1 < data.length; } public Object next(){ + idx++; Object res = data[idx]; - idx++; return res; } public void remove(){ @@ -2062,9 +2062,50 @@ } return -1; } + + class LocalListIterator : ListIterator { + int idx_next = 0; + public bool hasNext(){ + return idx_next < data.length; + } + public Object next(){ + Object res = data[idx_next]; + idx_next++; + return res; + } + public void remove(){ + implMissing( __FILE__, __LINE__ ); + this.outer.remove(idx_next); + idx_next--; + } + public void add(Object o){ + implMissing( __FILE__, __LINE__ ); + } + public bool add(String o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool hasPrevious(){ + return idx_next > 0; + } + public int nextIndex(){ + return idx_next; + } + public Object previous(){ + idx_next--; + Object res = data[idx_next]; + return res; + } + public int previousIndex(){ + return idx_next-1; + } + public void set(Object o){ + implMissing( __FILE__, __LINE__ ); + } + } + ListIterator listIterator(){ - implMissing( __FILE__, __LINE__ ); - return null; + return new LocalListIterator(); } ListIterator listIterator(int index){ implMissing( __FILE__, __LINE__ );