a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
/* ****************************************************************************
|
|
*
|
|
* Copyright (c) Microsoft Corporation.
|
|
*
|
|
* This source code is subject to terms and conditions of the Microsoft Public License. A
|
|
* copy of the license can be found in the License.html file at the root of this distribution. If
|
|
* you cannot locate the Microsoft Public License, please send an email to
|
|
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
|
|
* by the terms of the Microsoft Public License.
|
|
*
|
|
* You must not remove this notice, or any other, from this software.
|
|
*
|
|
*
|
|
* ***************************************************************************/
|
|
using System; using Microsoft;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Diagnostics;
|
|
|
|
#if CODEPLEX_40
|
|
namespace System.Dynamic {
|
|
#else
|
|
namespace Microsoft.Scripting {
|
|
#endif
|
|
internal static class CollectionExtensions {
|
|
|
|
internal static T[] RemoveFirst<T>(this T[] array) {
|
|
T[] result = new T[array.Length - 1];
|
|
Array.Copy(array, 1, result, 0, result.Length);
|
|
return result;
|
|
}
|
|
|
|
internal static T[] AddFirst<T>(this IList<T> list, T item) {
|
|
T[] res = new T[list.Count + 1];
|
|
res[0] = item;
|
|
list.CopyTo(res, 1);
|
|
return res;
|
|
}
|
|
|
|
internal static T[] ToArray<T>(this IList<T> list) {
|
|
T[] res = new T[list.Count];
|
|
list.CopyTo(res, 0);
|
|
return res;
|
|
}
|
|
|
|
internal static T[] AddLast<T>(this IList<T> list, T item) {
|
|
T[] res = new T[list.Count + 1];
|
|
list.CopyTo(res, 0);
|
|
res[list.Count] = item;
|
|
return res;
|
|
}
|
|
}
|
|
}
|