Beispiel #1
0
        private void HalfRange(Node range, SortedLinkedList ranges)
        {
            int middle = (int)Math.Floor((range.From + range.To) / 2.0);

            SeatsArray[middle] = People.GetCurrentNumber();

            if (range.From == range.To)
            {
                return;
            }

            Node right;

            if (range.From == middle)
            {
                right = new Node(middle + 1, range.To);
                ranges.AddNode(right);

                return;
            }

            Node left = new Node(range.From, middle - 1);

            ranges.AddNode(left);

            right = new Node(middle + 1, range.To);
            ranges.AddNode(right);
        }
Beispiel #2
0
        private void FillSeats()
        {
            SortedLinkedList ranges = new SortedLinkedList();

            ranges.AddNode(new Node(1, SeatsArray.Length - 1));

            while (ranges.Count != 0)
            {
                Node range = ranges.RemoveFirst();

                HalfRange(range, ranges);
            }
        }