Skip to content

Instantly share code, notes, and snippets.

@devboy
Created November 26, 2011 12:13
Show Gist options
  • Save devboy/1395537 to your computer and use it in GitHub Desktop.
Save devboy/1395537 to your computer and use it in GitHub Desktop.
package org.devboy;
class ArrayUtils
{
public static function delete_if<T>( array: Array<T>, processor: T -> Bool ): Array<T>
{
var remove: Array<T> = [];
for ( item in array )
if ( processor(item) )
remove.push( item );
for ( item in remove )
array.remove( item );
return array;
}
public static function keep_if<T>( array: Array<T>, processor: T -> Bool ): Array<T>
{
var remove: Array<T> = [];
for ( item in array )
if ( !processor(item) )
remove.push( item );
for ( item in remove )
array.remove( item );
return array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment