Beispiel #1
0
        public static void Mover(Video[] video, Nodo[] lista) {
            int act = 0, prev = -1, mov = 1;
            Video aux = new Video();
            bool[] ordenado = lista.Select(x => false).ToArray();

            Console.WriteLine();
            while(mov < lista.Length) {
                Console.WriteLine(act.ToString() + " " + prev.ToString());
                if(lista[act].origen == act) {
                    ordenado[act] = true;
                    act = Siguiente(ordenado);
                } else {
                    if(prev == -1) {
                        aux = video[act];
                        video[act] = video[lista[act].origen];
                        ordenado[act] = true;
                        prev = act;
                        act = lista[act].origen;
                    } else if(lista[act].origen != prev) {
                        video[act] = video[lista[act].origen];
                        ordenado[act] = true;
                        act = lista[act].origen;

                    } else {
                        video[act] = aux;
                        ordenado[act] = true;
                        prev = -1;
                        act = Siguiente(ordenado);
                    }
                }
                mov++;
                Console.WriteLine(act.ToString() + " " + prev.ToString());
                Console.WriteLine("Video: " + video.Select(x => x.ToString())
                                                   .Aggregate((x, xs) => x + " " + xs));
            }

            Console.WriteLine(ordenado.Select(x => x.ToString()).Aggregate((x, xs) => x + " " + xs));

            if(prev != -1) {
                video[act] = aux;
            }
        }
Beispiel #2
0
 public static Nodo[] Preparar(Video[] video) {
     int origen = 0;
     return video.Select(x => new Nodo(origen++, x.duración)).ToArray();
 }