Mercurial > projects > dwt2
diff java/src/java/util/HashSet.d @ 10:eb8ff453285d
Added java.util collection classes.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 13 Mar 2009 16:57:07 +0100 |
parents | |
children | 9b96950f2c3c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/util/HashSet.d Fri Mar 13 16:57:07 2009 +0100 @@ -0,0 +1,121 @@ +module java.util.HashSet; + +import java.lang.all; +import java.util.Set; +import java.util.Collection; +import java.util.Iterator; + +static import tango.util.container.HashSet; + +class HashSet : Set { + alias tango.util.container.HashSet.HashSet!(Object) SetType; + private SetType set; + + public this(){ + set = new SetType(); + } + public this(Collection c){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity){ + implMissing( __FILE__, __LINE__ ); + } + public this(int initialCapacity, float loadFactor){ + implMissing( __FILE__, __LINE__ ); + } + public bool add(Object o){ + return set.add(o); + } + public bool add(String o){ + return add(stringcast(o)); + } + public bool addAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public void clear(){ + set.clear(); + } + public bool contains(Object o){ + return set.contains(o); + } + public bool contains(String o){ + return contains(stringcast(o)); + } + public bool containsAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public override int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public override hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public bool isEmpty(){ + return set.isEmpty(); + } + class LocalIterator : Iterator { + SetType.Iterator iter; + Object nextElem; + this( SetType.Iterator iter){ + this.iter = iter; + } + public bool hasNext(){ + return iter.next(nextElem); + } + public Object next(){ + return nextElem; + } + public void remove(){ + iter.remove(); + } + } + public Iterator iterator(){ + return new LocalIterator(set.iterator()); + } + public bool remove(Object o){ + return set.remove(o); + } + public bool remove(String key){ + return remove(stringcast(key)); + } + public bool removeAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public bool retainAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + public int size(){ + return set.size(); + } + public Object[] toArray(){ + 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__ ); + return null; + } + public override String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + return set.opApply(dg); + } + +} +