Пример #1
0
 /// <summary>
 /// Step three:  All the remining items in smallList necessarily have probability of 100%
 /// </summary>
 private void AddRemainingProbabilityBoxes(Stack <KeyBallsPair> smallStack)
 {
     while (smallStack.Count != 0)
     {
         KeyBallsPair smallItem = smallStack.Pop();
         _probabilityBoxes.Add(new ProbabilityBox(smallItem.Key, smallItem.Key, _heightPerBox));
     }
 }
Пример #2
0
        /// <summary>
        /// Step two:  Pair up each item in the large/small lists and create a probability box for them
        /// </summary>
        private void CreateSplitProbabilityBoxes(Stack <KeyBallsPair> largeStack, Stack <KeyBallsPair> smallStack)
        {
            while (largeStack.Count != 0)
            {
                KeyBallsPair largeItem = largeStack.Pop();
                KeyBallsPair smallItem = smallStack.Pop();
                _probabilityBoxes.Add(new ProbabilityBox(smallItem.Key, largeItem.Key, smallItem.NumBalls));

                //Set the new weight for the largeList item, and move it to smallList if necessary
                long difference = _heightPerBox - smallItem.NumBalls;
                largeItem.NumBalls = largeItem.NumBalls - difference;
                if (largeItem.NumBalls > _heightPerBox)
                {
                    largeStack.Push(largeItem);
                }
                else
                {
                    smallStack.Push(largeItem);
                }
            }
        }