Esempio n. 1
0
        public string mListar()
        {
            @base t = _inicio;

            int    CicPend  = 0;
            int    ProPend  = 0;
            string _vCadena = "";


            if (_inicio != null)
            {
                do
                {
                    _vCadena += t.ToString();
                    CicPend  += t.Tiempo;

                    t = t.Siguiente;

                    ProPend++;
                } while (t != _inicio);
            }

            _proPen = ProPend;
            _cicPen = CicPend;

            return(_vCadena);
        }
Esempio n. 2
0
 public void Dequeue()
 {
     if (_inicio != null)
     {
         _inicio = _inicio.Siguiente;
     }
 }
Esempio n. 3
0
        public bool mEliminar(@base p1)
        {
            if (_inicio != null)
            {
                if (p1.Siguiente == _inicio && p1.Anterior == _inicio && p1 == _inicio)
                {
                    _inicio = null;
                }
                else if (p1 == _inicio)
                {
                    _inicio.Siguiente.Anterior = _inicio.Anterior;
                    _inicio.Anterior.Siguiente = _inicio.Siguiente;
                    _inicio = p1.Siguiente;
                }
                else if (p1.Siguiente == _inicio && p1.Anterior.Siguiente == p1)
                {
                    p1.Anterior.Siguiente = _inicio;
                    _inicio.Anterior      = p1.Anterior;
                }
                else
                {
                    p1.Siguiente.Anterior = p1.Anterior;
                    p1.Anterior.Siguiente = p1.Siguiente;
                }
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
 public void mMoverSiguiente()
 {
     if (_inicio != null)
     {
         _inicio = _inicio.Siguiente;
     }
 }
Esempio n. 5
0
        private void cmdInicio_Click(object sender, EventArgs e)
        {
            txtInfo.Clear();

            Proceador Procesador = new Proceador();
            Random    r          = new Random();
            @base     P1;

            int totalPro  = 0;
            int proEmpty  = 0;
            int numMaxPro = 0;

            for (int i = 0; i < 200; i++)
            {
                if (r.Next(1, 101) <= 30)
                {
                    P1 = new @base(r.Next(4, 13));
                    Procesador.mAgregar(P1);
                    P1.Proceso = numMaxPro;
                    numMaxPro++;
                }

                P1 = Procesador.mActual();

                if (P1 != null)
                {
                    P1.Tiempo--;

                    if (P1.Tiempo == 0)
                    {
                        Procesador.mEliminar(P1);
                        totalPro++;
                    }

                    Procesador.mMoverSiguiente();
                }
                else
                {
                    proEmpty++;
                }
            }

            txtInfo.Text = Procesador.mListar();

            txtMaximo.Text    = numMaxPro.ToString();
            txtAtendidos.Text = totalPro.ToString();
            txtRestantes.Text = proEmpty.ToString();
            txtVacios.Text    = Procesador._proPen.ToString();
            textBox1.Text     = Procesador._cicPen.ToString();
        }
Esempio n. 6
0
        public void Enqueue(@base nuevo)
        {
            if (_inicio == null)
            {
                _inicio = nuevo;
                _ultimo = nuevo;
                //_inicio.Siguiente = _ultimo;
            }
            else
            {
                @base t = _inicio;

                _ultimo.Siguiente = nuevo;
                _ultimo           = nuevo;
            }
        }
Esempio n. 7
0
        private void cmdInicio_Click(object sender, EventArgs e)
        {
            Proceador Procesador = new Proceador();
            Random    r          = new Random();
            @base     P1;

            int totalPro  = 0;
            int proEmpty  = 0;
            int numMaxPro = 0;
            int numPend   = 0;

            for (int i = 0; i < 200; i++)
            {
                if (r.Next(1, 101) <= 35)
                {
                    P1 = new @base(r.Next(4, 11));
                    Procesador.Enqueue(P1);
                    numMaxPro++;
                    numPend++;
                }

                P1 = Procesador.Peek;

                if (P1 != null)
                {
                    P1.Tiempo--;
                    if (P1.Tiempo == 0)
                    {
                        Procesador.Dequeue();
                        totalPro++;
                        numPend--;
                    }
                }
                else
                {
                    proEmpty++;
                }
            }

            txtMaximo.Text    = numMaxPro.ToString();
            txtAtendidos.Text = totalPro.ToString();
            txtRestantes.Text = proEmpty.ToString();
            txtVacios.Text    = numPend.ToString();
        }
Esempio n. 8
0
        public @base mBuscar(@base proceso)
        {
            if (_inicio != null)
            {
                do
                {
                    if (proceso.Siguiente == proceso)
                    {
                        return(proceso);
                    }
                    else
                    {
                        proceso = proceso.Siguiente;
                    }
                } while (proceso != _inicio);
            }

            return(null);
        }
Esempio n. 9
0
        public void mAgregar(@base nuevo)
        {
            if (_inicio == null)
            {
                _inicio           = nuevo;
                _inicio.Siguiente = _inicio;
                _inicio.Anterior  = _inicio;
            }
            else
            {
                @base t = _inicio;

                while (t.Siguiente != _inicio)
                {
                    t = t.Siguiente;
                }

                t.Siguiente      = nuevo;
                nuevo.Anterior   = t;
                nuevo.Siguiente  = _inicio;
                _inicio.Anterior = nuevo;
            }
        }