Example #1
0
    // performs {a: 0, b: 1}, {a: 6} -> [6, 0]
    private List <double> ToArray(AssociativeArray <int> lookup, AssociativeArray <double> obj)
    {
        int arrayLength = 0;

        foreach (var p in lookup)
        {
            ++arrayLength;
        }
        var result = Zeros(arrayLength);

        foreach (var p in lookup)
        {
            int key = lookup[p.Key];
            result[key] = obj.ContainsKey(p.Key) ? obj[p.Key] : 0;
        }
        return(result);
    }
Example #2
0
    private void CreateOutputLookup(OutputData output)
    {
        var data   = output.data[0];
        int length = 0;
        AssociativeArray <int> lookup = new AssociativeArray <int>();

        for (int i = 0; i < data.Count; ++i)
        {
            foreach (var p in data)
            {
                if (lookup.ContainsKey(p.Key))
                {
                    continue;
                }
                lookup[p.Key] = length++;
            }
        }
        outputLookup = lookup;
    }