Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Benchmark/ExampleConverter.cs @ 14727

Last change on this file since 14727 was 14727, checked in by pkimmesw, 7 years ago

#2665 PushGP HL Integration, Views, Parameters

File size: 648 bytes
Line 
1namespace Push.Data {
2  using System.Linq;
3
4  public static class ExampleConverter {
5    private const char ArrayValueSeparator = ' ';
6
7    private static readonly char[] arraySymbolTrim = { '[', ']' };
8
9    public static long Integer(string str) {
10      return long.Parse(str);
11    }
12
13    public static long[] Integers(string str) {
14      var values =
15        str.Trim(arraySymbolTrim).Split(ArrayValueSeparator).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
16
17      var result = new long[values.Count];
18
19      for (var i = 0; i < result.Length; i++) result[i] = Integer(values[i]);
20
21      return result;
22    }
23  }
24}
Note: See TracBrowser for help on using the repository browser.