214420a8bd249af0f252da43b43f4953f118fe7b
[ldk-java] / c_sharp / src / org / ldk / util / InternalUtils.cs
1 using System;
2 using org.ldk.util;
3
4 internal class InternalUtils {
5         public static T[] check_arr_len<T>(T[] arr, int length) {
6                 if (arr != null && arr.Length != length) {
7                         throw new ArgumentException("Array must be of fixed size " + length + " but was of length " + arr.Length);
8                 }
9                 return arr;
10         }
11
12         public static byte[] convUInt5Array(UInt5[] u5s) {
13                 byte[] res = new byte[u5s.Length];
14                 for (int i = 0; i < u5s.Length; i++) {
15                         res[i] = u5s[i].getVal();
16                 }
17                 return res;
18         }
19
20         public static T[] mapArray<F, T>(F[] arr, Func<F, T> f) {
21                 T[] ret = new T[arr.Length];
22                 for (int i = 0; i < arr.Length; i++) ret[i] = f(arr[i]);
23                 return ret;
24         }
25 }