Mercurial > projects > dwt-addons
diff dwtx/dwtxhelper/Collection.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | f8d52b926852 |
children | ee33f30b14e2 |
line wrap: on
line diff
--- a/dwtx/dwtxhelper/Collection.d Wed Aug 27 14:49:30 2008 +0200 +++ b/dwtx/dwtxhelper/Collection.d Mon Sep 08 00:51:37 2008 +0200 @@ -119,6 +119,7 @@ public bool addAll(int index, Collection c); public void clear(); public bool contains(Object o); + public bool contains(String o); public bool containsAll(Collection c); public int opEquals(Object o); public Object get(int index); @@ -1115,6 +1116,9 @@ public abstract bool addAll(int index, Collection c); public abstract void clear(); public abstract bool contains(Object o); + public bool contains(String str){ + return contains(stringcast(str)); + } public abstract bool containsAll(Collection c); public abstract int opEquals(Object o); public abstract Object get(int index); @@ -1331,6 +1335,9 @@ implMissing( __FILE__, __LINE__ ); return false; } + public bool contains(String str){ + return contains(stringcast(str)); + } public bool containsAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -1741,6 +1748,9 @@ bool contains(Object elem){ return list.contains(elem); } + bool contains(String elem){ + return contains(stringcast(elem)); + } bool containsAll(Collection c){ foreach(o; c){ if( !list.contains(o)) return false; @@ -1771,6 +1781,12 @@ Object get(int index){ return list.get(index); } + Object getFirst(){ + return list.get(0); + } + Object getLast(){ + return list.get(list.size()-1); + } hash_t toHash(){ implMissing( __FILE__, __LINE__ ); return 0; @@ -1949,6 +1965,9 @@ } return false; } + bool contains(String o){ + return contains(stringcast(o)); + } bool containsAll(Collection c){ implMissing( __FILE__, __LINE__ ); return false; @@ -2100,7 +2119,7 @@ } class Arrays { - public static bool equals(Object[] a, Object[] b){ + public static bool equals(T)(T[] a, T[] b){ if( a.length !is b.length ){ return false; } @@ -2115,6 +2134,34 @@ } return true; } +/+ public static bool equals(Object[] a, Object[] b){ + if( a.length !is b.length ){ + return false; + } + for( int i = 0; i < a.length; i++ ){ + if( a[i] is null && b[i] is null ){ + continue; + } + if( a[i] !is null && b[i] !is null && a[i] == b[i] ){ + continue; + } + return false; + } + return true; + } ++/ + static void sort( T )( T[] a, Comparator c ){ + bool isLess( T o1, T o2 ){ + return c.compare( cast(Object)o1, cast(Object)o2 ) < 0; + } + tango.core.Array.sort( a, &isLess ); + } + static void sort( T : char[] )( T[] a, Comparator c ){ + bool isLess( T o1, T o2 ){ + return c.compare( stringcast(o1), stringcast(o2) ) < 0; + } + tango.core.Array.sort( a, &isLess ); + } static List asList(Object[] a) { if( a.length is 0 ) return Collections.EMPTY_LIST; ArrayList res = new ArrayList( a.length ); @@ -2123,6 +2170,9 @@ } return res; } + public static void fill( String str, char c ){ + str[] = c; + } } class Collections { @@ -2228,4 +2278,8 @@ } } - +class LinkedHashMap : HashMap { + static this(){ + implMissing( __FILE__, __LINE__ ); + } +} \ No newline at end of file