Mercurial > projects > dwt2
diff java/src/java/util/TreeSet.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/TreeSet.d Fri Mar 13 16:57:07 2009 +0100 @@ -0,0 +1,136 @@ +module java.util.TreeSet; + +import java.lang.all; +import java.util.SortedSet; +import java.util.AbstractSet; +import java.util.Collection; +import java.util.Iterator; + +static import tango.util.container.SortedMap; + +class TreeSet : AbstractSet, SortedSet { + + alias tango.util.container.SortedMap.SortedMap!(Object,int) SetType; + private SetType set; + + public this(){ + set = new SetType(); + } + public this(Collection c){ + implMissing( __FILE__, __LINE__ ); + } + public this(Comparator c){ + implMissing( __FILE__, __LINE__ ); + } + public this(SortedSet){ + implMissing( __FILE__, __LINE__ ); + } + + public bool add(Object o){ + return set.add(o, 0); + } + public bool add(String o){ + return add(stringcast(o)); + } + public bool addAll(Collection c){ + foreach( o; c ){ + add(o); + } + return true; + } + public void clear(){ + set.clear(); + } + public bool contains(Object o){ + return set.containsKey(o); + } + public bool contains(String o){ + return contains(stringcast(o)); + } + public bool containsAll(Collection c){ + foreach( o; c ){ + if( !contains(o) ){ + return false; + } + } + return true; + } + public Comparator comparator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public override int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public Object first(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public override hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + public SortedSet headSet(Object toElement){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public bool isEmpty(){ + return set.isEmpty(); + } + public Iterator iterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object last(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public bool remove(Object o){ + return false; + } + 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 SortedSet subSet(Object fromElement, Object toElement){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public SortedSet tailSet(Object fromElement){ + implMissing( __FILE__, __LINE__ ); + return null; + } + public Object[] toArray(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + 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){ + int localDg( ref Object key, ref int value ){ + return dg( key ); + } + return set.opApply(&localDg); + } +} +