Mercurial > projects > dwt-addons
comparison 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 |
comparison
equal
deleted
inserted
replaced
161:f8d52b926852 | 162:1a5b8f8129df |
---|---|
117 public bool add(String o); | 117 public bool add(String o); |
118 public bool addAll(Collection c); | 118 public bool addAll(Collection c); |
119 public bool addAll(int index, Collection c); | 119 public bool addAll(int index, Collection c); |
120 public void clear(); | 120 public void clear(); |
121 public bool contains(Object o); | 121 public bool contains(Object o); |
122 public bool contains(String o); | |
122 public bool containsAll(Collection c); | 123 public bool containsAll(Collection c); |
123 public int opEquals(Object o); | 124 public int opEquals(Object o); |
124 public Object get(int index); | 125 public Object get(int index); |
125 public hash_t toHash(); | 126 public hash_t toHash(); |
126 public int indexOf(Object o); | 127 public int indexOf(Object o); |
1113 public abstract bool add(Object o); | 1114 public abstract bool add(Object o); |
1114 public abstract bool addAll(Collection c); | 1115 public abstract bool addAll(Collection c); |
1115 public abstract bool addAll(int index, Collection c); | 1116 public abstract bool addAll(int index, Collection c); |
1116 public abstract void clear(); | 1117 public abstract void clear(); |
1117 public abstract bool contains(Object o); | 1118 public abstract bool contains(Object o); |
1119 public bool contains(String str){ | |
1120 return contains(stringcast(str)); | |
1121 } | |
1118 public abstract bool containsAll(Collection c); | 1122 public abstract bool containsAll(Collection c); |
1119 public abstract int opEquals(Object o); | 1123 public abstract int opEquals(Object o); |
1120 public abstract Object get(int index); | 1124 public abstract Object get(int index); |
1121 | 1125 |
1122 public hash_t toHash(){ | 1126 public hash_t toHash(){ |
1329 } | 1333 } |
1330 public bool contains(Object elem){ | 1334 public bool contains(Object elem){ |
1331 implMissing( __FILE__, __LINE__ ); | 1335 implMissing( __FILE__, __LINE__ ); |
1332 return false; | 1336 return false; |
1333 } | 1337 } |
1338 public bool contains(String str){ | |
1339 return contains(stringcast(str)); | |
1340 } | |
1334 public bool containsAll(Collection c){ | 1341 public bool containsAll(Collection c){ |
1335 implMissing( __FILE__, __LINE__ ); | 1342 implMissing( __FILE__, __LINE__ ); |
1336 return false; | 1343 return false; |
1337 } | 1344 } |
1338 public void copyInto(Object[] anArray){ | 1345 public void copyInto(Object[] anArray){ |
1739 return null; | 1746 return null; |
1740 } | 1747 } |
1741 bool contains(Object elem){ | 1748 bool contains(Object elem){ |
1742 return list.contains(elem); | 1749 return list.contains(elem); |
1743 } | 1750 } |
1751 bool contains(String elem){ | |
1752 return contains(stringcast(elem)); | |
1753 } | |
1744 bool containsAll(Collection c){ | 1754 bool containsAll(Collection c){ |
1745 foreach(o; c){ | 1755 foreach(o; c){ |
1746 if( !list.contains(o)) return false; | 1756 if( !list.contains(o)) return false; |
1747 } | 1757 } |
1748 return true; | 1758 return true; |
1769 return null; | 1779 return null; |
1770 } | 1780 } |
1771 Object get(int index){ | 1781 Object get(int index){ |
1772 return list.get(index); | 1782 return list.get(index); |
1773 } | 1783 } |
1784 Object getFirst(){ | |
1785 return list.get(0); | |
1786 } | |
1787 Object getLast(){ | |
1788 return list.get(list.size()-1); | |
1789 } | |
1774 hash_t toHash(){ | 1790 hash_t toHash(){ |
1775 implMissing( __FILE__, __LINE__ ); | 1791 implMissing( __FILE__, __LINE__ ); |
1776 return 0; | 1792 return 0; |
1777 } | 1793 } |
1778 int indexOf(Object elem){ | 1794 int indexOf(Object elem){ |
1946 if( o == v ){ | 1962 if( o == v ){ |
1947 return true; | 1963 return true; |
1948 } | 1964 } |
1949 } | 1965 } |
1950 return false; | 1966 return false; |
1967 } | |
1968 bool contains(String o){ | |
1969 return contains(stringcast(o)); | |
1951 } | 1970 } |
1952 bool containsAll(Collection c){ | 1971 bool containsAll(Collection c){ |
1953 implMissing( __FILE__, __LINE__ ); | 1972 implMissing( __FILE__, __LINE__ ); |
1954 return false; | 1973 return false; |
1955 } | 1974 } |
2098 return 0; | 2117 return 0; |
2099 } | 2118 } |
2100 } | 2119 } |
2101 | 2120 |
2102 class Arrays { | 2121 class Arrays { |
2103 public static bool equals(Object[] a, Object[] b){ | 2122 public static bool equals(T)(T[] a, T[] b){ |
2104 if( a.length !is b.length ){ | 2123 if( a.length !is b.length ){ |
2105 return false; | 2124 return false; |
2106 } | 2125 } |
2107 for( int i = 0; i < a.length; i++ ){ | 2126 for( int i = 0; i < a.length; i++ ){ |
2108 if( a[i] is null && b[i] is null ){ | 2127 if( a[i] is null && b[i] is null ){ |
2112 continue; | 2131 continue; |
2113 } | 2132 } |
2114 return false; | 2133 return false; |
2115 } | 2134 } |
2116 return true; | 2135 return true; |
2136 } | |
2137 /+ public static bool equals(Object[] a, Object[] b){ | |
2138 if( a.length !is b.length ){ | |
2139 return false; | |
2140 } | |
2141 for( int i = 0; i < a.length; i++ ){ | |
2142 if( a[i] is null && b[i] is null ){ | |
2143 continue; | |
2144 } | |
2145 if( a[i] !is null && b[i] !is null && a[i] == b[i] ){ | |
2146 continue; | |
2147 } | |
2148 return false; | |
2149 } | |
2150 return true; | |
2151 } | |
2152 +/ | |
2153 static void sort( T )( T[] a, Comparator c ){ | |
2154 bool isLess( T o1, T o2 ){ | |
2155 return c.compare( cast(Object)o1, cast(Object)o2 ) < 0; | |
2156 } | |
2157 tango.core.Array.sort( a, &isLess ); | |
2158 } | |
2159 static void sort( T : char[] )( T[] a, Comparator c ){ | |
2160 bool isLess( T o1, T o2 ){ | |
2161 return c.compare( stringcast(o1), stringcast(o2) ) < 0; | |
2162 } | |
2163 tango.core.Array.sort( a, &isLess ); | |
2117 } | 2164 } |
2118 static List asList(Object[] a) { | 2165 static List asList(Object[] a) { |
2119 if( a.length is 0 ) return Collections.EMPTY_LIST; | 2166 if( a.length is 0 ) return Collections.EMPTY_LIST; |
2120 ArrayList res = new ArrayList( a.length ); | 2167 ArrayList res = new ArrayList( a.length ); |
2121 foreach( o; a ){ | 2168 foreach( o; a ){ |
2122 res.add(o); | 2169 res.add(o); |
2123 } | 2170 } |
2124 return res; | 2171 return res; |
2172 } | |
2173 public static void fill( String str, char c ){ | |
2174 str[] = c; | |
2125 } | 2175 } |
2126 } | 2176 } |
2127 | 2177 |
2128 class Collections { | 2178 class Collections { |
2129 | 2179 |
2226 implMissing( __FILE__, __LINE__ ); | 2276 implMissing( __FILE__, __LINE__ ); |
2227 return null; | 2277 return null; |
2228 } | 2278 } |
2229 } | 2279 } |
2230 | 2280 |
2231 | 2281 class LinkedHashMap : HashMap { |
2282 static this(){ | |
2283 implMissing( __FILE__, __LINE__ ); | |
2284 } | |
2285 } |