예제 #1
0
        // funkcja tworzaca stog oraz inicjalizujaca funkcje testowa /
        static TimeSpan TestOfHeap(int A, int B, int M, int N)
        {
            // zwraca czas wykonania testu
            Heap<int> heap = new Heap<int>(A + 1);

            return heap.Test(A, B, M, N);
        }
예제 #2
0
        double[] TotalServingTime; //

        #endregion Fields

        #region Constructors

        public Simulation()
        {
            TotalOccupancyOfRouter = 0;
            Package ProcessedPackage = new Package();
            NumberOfStreams = 0;
            GetData();
            TimeOfSimulation = CurrentTime =AuxilaryTime= 0;
            occupancyOfRouter = false;
            eventQueue=new Heap();
            NumberOfReceivedPackages = new double[NumberOfStreams + 1];
            NumberOfServedPackages = new double[NumberOfStreams + 1];
            ProbabilityOfFailure = new double[NumberOfStreams + 1];
            AverageServingTime = new double[NumberOfStreams + 1];
            TotalServingTime = new double[NumberOfStreams + 1];
            AverageOccupancyOfqueue = new double[NumberOfStreams];
            TotalOccupancyOfQueue = new double[NumberOfStreams];
            rejected = new double[NumberOfStreams +1];
            TotalOccupancyOfRouter = 0;
            AverageOccupancyOfRouter = 0;
            for (int i=0;i<=NumberOfStreams;i++)
            {
                rejected[i] = 0;
                TotalServingTime[i] = 0;
                AverageServingTime[i] = 0;
                NumberOfReceivedPackages[i] = 0;
                NumberOfServedPackages[i] = 0;
                ProbabilityOfFailure[i] = 0;
            }
            for (int i = 0; i < NumberOfStreams; i++)
            {
                AverageOccupancyOfqueue[i] = 0;
                TotalOccupancyOfQueue[i] = 0;
            }
        }
예제 #3
0
        public void HeapTest()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            Heap<int> heap = new Heap<int>(numberOfInsertedElements + 1);

            for (int i = 0; i < numberOfInsertedElements; i++)
            {
                heap.Insert(o[i]);
            }
            stopWatch.Stop();
            Console.WriteLine("Inserting into Heap time: {0}", stopWatch.Elapsed);

            stopWatch.Start();
            heap.Check();
            Console.WriteLine("max index = {0}", heap.Max());
            for (int i = 0; i < numberOfDeletedElements; i++ )
                heap.DeleteMax();
            heap.Insert(o[numberOfInsertedElements]);
            stopWatch.Stop();
            Console.WriteLine("Deleting from Heap and inserting one element time: {0}", stopWatch.Elapsed);
        }