2018-02-13 09:23:53 -08:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
// Licensed under the MIT License.
|
2016-03-30 14:20:52 -07:00
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
namespace System.Management.Automation.ComInterop
|
|
|
|
|
{
|
|
|
|
|
internal static class CollectionExtensions
|
|
|
|
|
{
|
|
|
|
|
internal static T[] RemoveFirst<T>(this T[] array)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
T[] result = new T[array.Length - 1];
|
|
|
|
|
Array.Copy(array, 1, result, 0, result.Length);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
internal static T[] AddFirst<T>(this IList<T> list, T item)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
T[] res = new T[list.Count + 1];
|
|
|
|
|
res[0] = item;
|
|
|
|
|
list.CopyTo(res, 1);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
internal static T[] ToArray<T>(this IList<T> list)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
T[] res = new T[list.Count];
|
|
|
|
|
list.CopyTo(res, 0);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-29 13:02:49 -07:00
|
|
|
internal static T[] AddLast<T>(this IList<T> list, T item)
|
|
|
|
|
{
|
2016-03-30 14:20:52 -07:00
|
|
|
T[] res = new T[list.Count + 1];
|
|
|
|
|
list.CopyTo(res, 0);
|
|
|
|
|
res[list.Count] = item;
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|