Ejemplo n.º 1
0
        // listOfWorkers.RemoveWorkers(listOfWorkers.Workers[0]);
        private void Resize(ChoiseResize resize)
        {
            IWorker[] tmp;
            switch (resize)
            {
            case ChoiseResize.UP:
            {
                _currentCopacity += _capacity;
                break;
            }

            case ChoiseResize.DOWN:
            {
                if (_counter <= _currentCopacity - _capacity)
                {
                    _currentCopacity -= _capacity;
                    tmp = new IWorker[_currentCopacity];
                    for (int i = 0; i < _counter; i++)
                    {
                        tmp[i] = _workers[i];
                    }
                }
                break;
            }
            }
            tmp = new IWorker[_currentCopacity];
            for (int i = 0; i < _counter; i++)
            {
                tmp[i] = _workers[i];
            }
            _workers = tmp;
        }
Ejemplo n.º 2
0
        //listOfWorkers.RemoveWorker(listOfWorkers.Workers[0]);
        private void Resize(ChoiseResize resize)
        {
            IWorker[] tmp;
            switch (resize)
            {
            case ChoiseResize.UP:
            {
                _currentCapacity += _capacity;
                break;
            }

            case ChoiseResize.DOWN:
            {
                if (_currentCapacity == _capacity)
                {
                    break;
                }
                if (_counter < _currentCapacity - _capacity)
                {
                    _currentCapacity -= _capacity;
                }
                else if (_counter > _currentCapacity)
                {
                    throw new ArgumentOutOfRangeException("Неконтролируемое перераспределение");
                }
                break;
            }
            }
            tmp = new IWorker[_currentCapacity];
            for (int i = 0; i < _counter; i++)
            {
                tmp[i] = _workers[i];
            }
            _workers = tmp;
        }
Ejemplo n.º 3
0
        //listOfWorkers.RemoveWorker(listOfWorkers.Workers[0]);
        private void Resize(ChoiseResize resize)
        {
            IWorker[] tmp;
            switch (resize)
            {
            case ChoiseResize.UP:
            {
                _currentCapacity += _capacity;           //  _currentCapacity =_currentCapacity + _capacity = 80 + 8 = 88
                break;
            }

            case ChoiseResize.DOWN:
            {
                if (_currentCapacity == _capacity)
                {
                    break;
                }
                // _counter = 71 -- количество рабочих
                // _currentCapacity = 80 -- количество ячеек в массиве
                // _capacity = 8 -- всегда равно 8, константа
                if (_counter < _currentCapacity - _capacity) // 71 < 80 - 8
                {
                    _currentCapacity -= _capacity;           //  _currentCapacity =_currentCapacity - _capacity = 80 - 8 = 72
                }
                else if (_counter > _currentCapacity)
                {
                    throw new ArgumentOutOfRangeException("Неконтролируемое перераспределение");
                }
                break;
            }
            }
            tmp = new IWorker[_currentCapacity];
            for (int i = 0; i < _counter; i++)
            {
                tmp[i] = _workers[i];
            }
            _workers = tmp;
        }