org.opensubsystems.core.util
Class ArrayUtils

java.lang.Object
  extended by org.opensubsystems.core.util.ArrayUtils

public final class ArrayUtils
extends java.lang.Object

Collection of useful utilities to work with arrays.

Version:
$Id: ArrayUtils.java,v 1.9 2007/01/23 06:00:30 bastafidli Exp $
Author:
Peter Satury
Code reviewer:
Miro Halas
Code reviewed:
1.5 2005/07/29 07:36:24 bastafidli

Method Summary
static int contains(int[] source, int iTarget)
          Test if specified array contains given element and if it does, find its position.
static int[] exclude(int[] arrBase, int[] arrExclude)
          Method to exclude 2 arrays of ints so that the result contains all elements from the first array, which are not in the second array.
static long sum(int[] source)
          Sum all elements in the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

exclude

public static int[] exclude(int[] arrBase,
                            int[] arrExclude)
Method to exclude 2 arrays of ints so that the result contains all elements from the first array, which are not in the second array.

Parameters:
arrBase - - base array to exclude from
arrExclude - - array to exclude from the first one
Returns:
int[] - array which contains all elements from the first array which are not in the second array or null

contains

public static int contains(int[] source,
                           int iTarget)
Test if specified array contains given element and if it does, find its position.

Parameters:
source - - array to search, can be null
iTarget - - element to find
Returns:
int - -1 if it doesn't exist there otherwise its position

sum

public static long sum(int[] source)
Sum all elements in the array.

Parameters:
source - - array to sum elements of
Returns:
long - sum of the elements in the array


Copyright © 2003 - 2006 OpenSubsystems s.r.o.