# HG changeset patch # User Frank Benoit # Date 1224334948 -7200 # Node ID 26589d623405fd48519e84771bea3eec429d2eb9 # Parent c36336245fb1107f32cdcdd7746b62a85714d0e1 Added ListIterator for ArrayList diff -r c36336245fb1 -r 26589d623405 dwtx/dwtxhelper/Collection.d --- 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__ );