Beispiel #1
0
        public PerKeyArray <HashSet <SNote> > FetchSelectedNotes(PerKeyArray <HashSet <int> > selector)
        {
            var rets = PerKeyArray.Create(() => new HashSet <SNote>());

            Parallel.For(0, Constants.KeyCount, i =>
            {
                var select = selector[i];
                var ret    = rets[i];
                var key    = Notes[i];

                foreach (var idx in select)
                {
                    try
                    {
                        ret.Add(key[idx]);
                    }
                    catch
                    {
                        throw new DataIntegrityException("Invalid indexes were passed into the note selection fetcher");
                    }
                }
            });

            return(rets);
        }
Beispiel #2
0
        public PerKeyArray <HashSet <int> > GetNoteLocations(IEnumerable <SelectedSNote> selection)
        {
            var separatedSelection = PerKeyArray.Create(() => new List <SNote>());

            foreach (var n in selection)
            {
                separatedSelection[n.Key].Add(n.Note);
            }

            return(GetNoteLocations(separatedSelection.Map(k => k.AsEnumerable())));
        }
Beispiel #3
0
        public PerKeyArray <HashSet <int> > GetNoteLocations(PerKeyArray <IEnumerable <SNote> > separatedSelection)
        {
            var locations = PerKeyArray.Create(() => new HashSet <int>());

            Parallel.For(0, Constants.KeyCount, i =>
            {
                var selection    = separatedSelection[i];
                var notes        = Notes[i];
                var locationsKey = locations[i];

                foreach (var s in selection)
                {
                    var idx = notes.IndexOf(s);
                    if (idx == -1)
                    {
                        throw new DataIntegrityException("Invalid notes were passed into the note location finder");
                    }
                    locationsKey.Add(idx);
                }
            });
            return(locations);
        }