コード例 #1
0
        private void WriteBuf(ulong[] buf, int id)
        {
            Array.Sort(buf);

            var name = GetName(id);

            SpatialData.WriteSequence(buf, name);

            FileWritten(id, 0);
        }
コード例 #2
0
        private void Merge(int level, int[] fileIds, int resultFileId)
        {
            var source = CreateMergedSource(fileIds);

            SpatialData.WriteSequence(source, GetName(resultFileId));

            FileWritten(resultFileId, level);
            foreach (var fileId in fileIds)
            {
                File.Delete(GetName(fileId));
            }
        }
コード例 #3
0
        private IEnumerable <ulong> CreateMergedSource(int[] fileIds)
        {
            var sources = fileIds.Select(id => SpatialData.ReadSequence(GetName(id))).ToList();

            while (sources.Count > 1)
            {
                var newSources = new List <IEnumerable <ulong> >();
                for (var i = 0; i < sources.Count; i += 2)
                {
                    if (i + 1 < sources.Count)
                    {
                        newSources.Add(MergeSorted(sources[i], sources[i + 1]));
                    }
                    else
                    {
                        newSources.Add(sources[i]);
                    }
                }

                sources = newSources;
            }

            return(sources[0]);
        }