Commit c8fff6ab authored by An Ionescu's avatar An Ionescu

Adding generic (as in nondescript, not type generic) helper class. Should...

Adding generic (as in nondescript, not type generic) helper class. Should split into properly named static classes once it gets more populated.
parent 8602c862
using System;
using System.Collections.Generic;
using System.Linq;
namespace Anvoker.Collections.Maps.Tests
public static class HelperMethods
public static TCollection[] UnionValues<TCollection, TValue>(
TCollection[] first,
TCollection[] second,
IEqualityComparer<TValue> comparer,
Func<IEnumerable<TValue>, TCollection> colConstructor)
where TCollection : IEnumerable<TValue>
TCollection[] longer;
TCollection[] shorter;
if (first.Length > second.Length)
longer = first;
shorter = second;
longer = second;
shorter = first;
var values = new TCollection[longer.Length];
for (int i = 0; i < longer.Length; i++)
if (i < shorter.Length)
values[i] = colConstructor(
longer[i].Union(shorter[i], comparer));
values[i] = longer[i];
return values;
\ No newline at end of file
fileFormatVersion: 2
guid: ee7cda3887132c4438b5e75aea42a870
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment