/*
Copyright 1999 CERN - European Organization for Nuclear Research.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
is hereby granted without fee, provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in supporting documentation.
CERN makes no representations about the suitability of this software for any purpose.
It is provided "as is" without expressed or implied warranty.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DiscoveryLogic.Common.Numeric
{
/// Array manipulations; complements java.util.Arrays.
///
///
///
///
///
///
///
/// wolfgang.hoschek@cern.ch
///
/// 1.0, 03-Jul-99
///
public class Arrays : System.Object
{
/// Makes this class non instantiable, but still let's others inherit from it.
protected internal Arrays()
{
}
/// Ensures that the specified array cannot hold more than maxCapacity elements.
/// An application can use this operation to minimize array storage.
///
/// Returns the identical array if array.length <= maxCapacity.
/// Otherwise, returns a new array with a length of maxCapacity
/// containing the first maxCapacity elements of array.
///
///
/// the desired maximum capacity.
///
public static bool[] trimToCapacity(bool[] array, int maxCapacity)
{
if (array.Length > maxCapacity)
{
bool[] oldArray = array;
array = new bool[maxCapacity];
Array.Copy(oldArray, 0, array, 0, maxCapacity);
}
return array;
}
}
}