added filterNot method

This commit is contained in:
James Strachan
2011-12-23 16:27:40 +00:00
parent 310a49eaff
commit 3fa49cadc0
4 changed files with 37 additions and 0 deletions
@@ -41,6 +41,15 @@ inline fun <T> Array<T>.filter(result: Collection<T> = ArrayList<T>(), predicate
return result
}
/** Returns a new collection containing all elements in this collection which do not match the given predicate */
inline fun <T> Array<T>.filterNot(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> {
for (elem in this) {
if (!predicate(elem))
result.add(elem)
}
return result
}
/**
* Returns the result of transforming each item in the collection to a one or more values which
* are concatenated together into a single collection