// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
namespace Microsoft.MixedReality.Toolkit
{
///
/// type method extensions.
///
public static class ArrayExtensions
{
///
/// Wraps the index around to the beginning of the array if the provided index is longer than the array.
///
/// The array to wrap the index around.
/// The index to look for.
public static int WrapIndex(this Array array, int index)
{
int length = array.Length;
return ((index % length) + length) % length;
}
///
/// Checks whether the given array is not null and has at least one entry
///
public static bool IsValidArray(this Array array)
{
return array != null && array.Length > 0;
}
}
}