Beispiel #1
0
        private void NaiveHeapRandomOperations(IReadOnlyList <KeyValuePair <int, int> > startingKeyValuePairs)
        {
            var naiveHeap         = new NaiveHeap <int, int>(startingKeyValuePairs);
            int randomValuesIndex = 0;

            foreach (int operation in _randomOperations)
            {
                if (operation == 1 || naiveHeap.Size <= 1)
                {
                    naiveHeap.Add(++_key, _randomValues[randomValuesIndex++]);
                }
                else if (operation == 2)
                {
                    naiveHeap.Extract();
                }
                else if (operation == 3)
                {
                    naiveHeap.Replace(++_key, _randomValues[randomValuesIndex++]);
                }
                else
                {
                    var top = naiveHeap.Top;
                }
            }
        }
Beispiel #2
0
        private void NaiveHeapPrimSimulation()
        {
            var naiveHeap = new NaiveHeap <int, int>(_startingKeyValuePairsBig);

            foreach (Tuple <int, int> randomOperation in _randomPrimOperations)
            {
                if (randomOperation == null)
                {
                    naiveHeap.Extract();
                }
                else
                {
                    if (naiveHeap.Contains(randomOperation.Item1))
                    {
                        naiveHeap.Update(randomOperation.Item1, randomOperation.Item2);
                    }
                }
            }
        }