Created
November 26, 2011 12:13
-
-
Save devboy/1395537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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