public LinkedFile(int index, NumberRange range)
            {
                this.FileIndex   = index;
                this.NumberRange = range;
                this.Child       = null;
                this.Next        = null;

                if (Root == null)
                {
                    Root = this;
                }
            }
Exemple #2
0
        private NumberRange GetNextRange()
        {
            NumberRange nextRange = null;

            foreach (var subRange in SubRanges)
            {
                if (subRange.IsGenerated == false)
                {
                    nextRange = subRange;
                    break;
                }
            }
            return(nextRange);
        }
        private void GenerateRandomNumbersFromRangesRandomly(UniqueRandom uniqueRandom, FileDetails fileDetails)
        {
            var randomSubRange = new NumberRange(0, uniqueRandom.SubRanges.Count);
            var randomIndex    = randomSubRange.NextUnique();
            var fileIndex      = 0;

            while (randomIndex != null)
            {
                var subRange   = uniqueRandom.SubRanges[(int)randomIndex];
                var threadData = new ThreadData()
                {
                    FileDetails = fileDetails,
                    Range       = subRange,
                    RangeIndex  = fileIndex++
                };
                ThreadPool.QueueUserWorkItem(this.WriteNumbersToDiskFileForSubRanges, threadData);
                randomIndex = randomSubRange.NextUnique();
            }
        }
            public static void Build(int fileCount, int minValue, int maxValue, string directory)
            {
                Path = directory;

                LinkedFile current = null;

                if (Root == null)
                {
                    CurrentIndex = 0;
                    CurrentRange = new NumberRange(minValue, maxValue);
                    Root         = new LinkedFile(CurrentIndex++, CurrentRange++);
                    current      = Root;
                }

                for (var i = 1; i < fileCount; i++)
                {
                    var linkedFile = new LinkedFile(CurrentIndex++, CurrentRange++);
                    current.Next = linkedFile;
                    current      = current.Next;
                }
            }