Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using Microsoft.Research.DynamicDataDisplay.Charts;
|
---|
| 6 |
|
---|
| 7 | namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
|
---|
| 8 | {
|
---|
| 9 | internal static class ArrayExtensions
|
---|
| 10 | {
|
---|
| 11 | internal static T Last<T>(this T[] array) {
|
---|
| 12 | return array[array.Length - 1];
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | internal static T[] CreateArray<T>(int length, T defaultValue)
|
---|
| 16 | {
|
---|
| 17 | T[] res = new T[length];
|
---|
| 18 | for (int i = 0; i < res.Length; i++)
|
---|
| 19 | {
|
---|
| 20 | res[i] = defaultValue;
|
---|
| 21 | }
|
---|
| 22 | return res;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | internal static IEnumerable<Range<T>> GetPairs<T>(this IList<T> array)
|
---|
| 26 | {
|
---|
| 27 | if (array == null)
|
---|
| 28 | throw new ArgumentNullException("array");
|
---|
| 29 |
|
---|
| 30 | for (int i = 0; i < array.Count - 1; i++)
|
---|
| 31 | {
|
---|
| 32 | yield return new Range<T>(array[i], array[i + 1]);
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.