Exemplo n.º 1
0
        //Botton "Export Data"
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                int START_ROW = 9;
                int START_COL = 3;
                Excel.Worksheet active_worksheet = Globals.ThisAddIn.Application.ActiveSheet;

                //Acquire Target Data and Export
                Target TargetData = new Target();
                TargetData.GetData(active_worksheet);
                TargetData.ExportData();

                //Acquire Comparable Data and Export
                for (int col_index = START_COL; active_worksheet.Cells[START_ROW, col_index].Value != null ; col_index ++)
                {
                    Comparable comparable_data = new Comparable();
                    comparable_data.GetData(active_worksheet, START_ROW, col_index);
                    comparable_data.ExportData();
                }

                MessageBox.Show("Successfully export data.");
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.ToString());

            }
        }
        public Comparable minimo()
        {
            Comparable minimo = this.pila[0];

            for (int i = 0; i < this.cuantos(); i++)
            {
                if (this.pila[i].sosMenor(minimo))
                {
                    minimo = this.pila[i];
                }
            }
            return(minimo);
        }
        public bool contiene(Comparable obj)
        {
            bool existe = false;

            foreach (Comparable elemento in datos)
            {
                if (comparador.esIgual((Comparable)elemento, (Comparable)obj))
                {
                    existe = true;
                }
            }
            return(existe);
        }
        public bool pertenece(Comparable obj)
        {
            bool existe = false;

            foreach (Comparable elemento in datos)
            {
                if (elemento.sosIgual(obj))
                {
                    existe = true;
                }
            }
            return(existe);
        }
        public Comparable mayor()
        {
            Comparable maximo = this.datos[0];

            foreach (Comparable elemento in datos)
            {
                if (comparador.esMayor((ClaveValor)elemento, (ClaveValor)maximo))
                {
                    maximo = elemento;
                }
            }
            return(maximo);
        }
        public void UnlessGtHelper_renders_expected_result_when_not_greater()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Comparable {
                Thing = "b"
            };

            var result = Render.StringToString("{{#unless_gt one compare=two}}less{{/unless_gt}}", new { one, two });

            result.Should().Be("less");
        }
        public void IfGtHelper_renders_inverse_when_not_greater()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Comparable {
                Thing = "b"
            };

            var result = Render.StringToString("{{#if_gt one compare=two}}greater{{else}}less{{/if_gt}}", new { one, two });

            result.Should().Be("less");
        }
        public void IfGtHelper_renders_expected_result_when_not_greater()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Comparable {
                Thing = "b"
            };

            var result = Render.StringToString("{{#if_gt one compare=two}}greater{{/if_gt}}", new { one, two });

            result.Should().BeEmpty();
        }
        public void UnlessGtEqHelper_renders_expected_result_when_equal()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Comparable {
                Thing = "a"
            };

            var result = Render.StringToString("{{#unless_gteq one compare=two}}less{{/unless_gteq}}", new { one, two });

            result.Should().BeEmpty();
        }
        public void IfGtEqHelper_renders_expected_result_when_equal()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Comparable {
                Thing = "a"
            };

            var result = Render.StringToString("{{#if_gteq one compare=two}}greater{{/if_gteq}}", new { one, two });

            result.Should().Be("greater");
        }
Exemplo n.º 11
0
        public Comparable mayor()
        {
            Comparable maximo = datos[0];

            foreach (Comparable elemento in datos)
            {
                if (((Comparable)elemento).sosMayor(maximo))
                {
                    maximo = elemento;
                }
            }
            return(maximo);
        }
Exemplo n.º 12
0
        /// <summary> Remove the smallest item from the priority queue.</summary>
        /// <returns> the smallest item, or null, if empty.
        /// </returns>
        public virtual Comparable deleteMin()
        {
            if (Empty)
            {
                return(null);
            }

            Comparable minItem = findMin();

            array[1] = array[currentSize--];
            percolateDown(1);

            return(minItem);
        }
        public Comparable minimo()
        {
            Comparable minPila = this.pila.minimo();
            Comparable minCola = this.cola.minimo();

            if (minPila.sosMenor(minCola))
            {
                return(minPila);
            }
            else
            {
                return(minCola);
            }
        }
Exemplo n.º 14
0
        /// <summary> Insert into the priority queue, and return a PairNode
        /// that can be used by decreaseKey.
        /// Duplicates are allowed.
        /// </summary>
        /// <param name="x">the item to insert.
        /// </param>
        /// <returns> the node containing the newly inserted item.
        /// </returns>
        public virtual PairNode insert(Comparable x)
        {
            PairNode newNode = new PairNode(x);

            if (root == null)
            {
                root = newNode;
            }
            else
            {
                root = compareAndLink(root, newNode);
            }
            return(newNode);
        }
        public bool contiene(Comparable comparable)
        {
            bool tienepila = this.pila.contiene(comparable);
            bool tienecola = this.cola.contiene(comparable);

            if (tienepila || tienecola)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 16
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (count > _available)
            {
                throw new InvalidOperationException("Exceeded write operation limit.");
            }

            if (_available > 0 && count > 0)
            {
                int write = (int)Comparable.Min(_available, count);
                _stream.Write(buffer, offset, write);
                _available -= write;
            }
        }
        public Comparable maximo()
        {
            Comparable maxPila = this.pila.maximo();
            Comparable maxCola = this.cola.maximo();

            if (maxPila.sosMayor(maxCola))
            {
                return(maxPila);
            }
            else
            {
                return(maxCola);
            }
        }
Exemplo n.º 18
0
        public bool pertenece(Comparable comparable)
        {
            bool existeElemento = false;

            for (int i = 0; i < this.conjunto.Count; i++)
            {
                if (this.conjunto[i].sosIgual(comparable))
                {
                    existeElemento = true;
                }
            }

            return(existeElemento);
        }
Exemplo n.º 19
0
        public void UnlessLtEqHelper_renders_inverse_when_not_less()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Comparable {
                Thing = "b"
            };

            var result = Render.StringToString("{{#unless_lteq one compare=two}}less{{else}}less{{/unless_lteq}}",
                                               new { one, two });

            result.Should().Be("less");
        }
        public void Agregar(object valor, Comparable clave)
        {
            ClaveValor claveValor = new ClaveValor(valor, clave);

            foreach (Comparable a in conjunto.getConjunto())
            {
                if (((ClaveValor)a).sosIgual(claveValor))
                {
                    ((ClaveValor)a).setValor(valor);
                    break;
                }
            }
            conjunto.agregar(claveValor);
        }
Exemplo n.º 21
0
        public void IfLtHelper_throws_when_not_comparable()
        {
            var one = new Comparable {
                Thing = "a"
            };
            var two = new Incomparable {
                Thing = "b"
            };

            Action action =
                () => Render.StringToString("{{#if_lt one compare=two}}less{{else}}less{{/if_lt}}", new { one, two });

            action.ShouldThrow <InvalidOperationException>().WithMessage(
                "The objects being compared must implement IComparable.");
        }
        public Comparable maximo()
        {
            Comparable maximo = this.cola[0];

            {
                for (int i = 0; i < this.cuantos(); i++)
                {
                    if (this.cola[i].sosMayor(maximo))
                    {
                        maximo = this.cola[i];
                    }
                }
            }
            return(maximo);
        }
 public void agregar(Comparable comparable)
 {
     this.Agregar(comparable, clave = new Numero(((Numero)clave).getValor() + 1));
     if (this.cuantos() == 1 & this.ordenInicio != null)
     {
         this.ordenInicio.ejecutar();
     }
     if (this.ordenLlegaAlumno != null)
     {
         this.ordenLlegaAlumno.ejecutar(comparable);
     }
     if (this.cuantos() == 40 & this.ordenEnAulaLlena != null)
     {
         this.ordenEnAulaLlena.ejecutar();
     }
 }
        public bool contiene(Comparable obj)
        {
            bool existe = false;

            if (this.datos.Count > 0)
            {
                foreach (Comparable elemento in datos)
                {
                    if (comparador.esIgual(elemento, obj))
                    {
                        existe = true;
                    }
                }
            }
            return(existe);
        }
 public int CompareTo(TNode other, Comparable <TNode> compare)
 {
     if (compare == null && other is IComparable <TNode> )
     {
         IComparable <TNode> value = other as IComparable <TNode>;
         return(value.CompareTo(Value));
     }
     else if (compare != null)
     {
         return(compare.Invoke(other, Value));
     }
     else
     {
         throw new ComparatorHasNotBeenFoundException("Comparator has not been found check it and try again.");
     }
 }
Exemplo n.º 26
0
        /// <summary> Insert into the priority queue, maintaining heap order.
        /// Duplicates are allowed.
        /// </summary>
        /// <param name="x">the item to insert.
        /// </param>
        /// <exception cref="Overflow">if container is full.
        /// </exception>
        public virtual void  insert(Comparable x)
        {
            if (Full)
            {
                throw new Overflow();
            }

            // Percolate up
            int hole = ++currentSize;

            for (; hole > 1 && x.compareTo(array[hole / 2]) < 0; hole /= 2)
            {
                array[hole] = array[hole / 2];
            }
            array[hole] = x;
        }
 public void agregar(Comparable parametro)
 {
     this.pila.Add(parametro);
     if (this.cuantos() == 1 & this.ordenInicio != null)
     {
         this.ordenInicio.ejecutar();
     }
     if (this.ordenLlegaAlumno != null)
     {
         this.ordenLlegaAlumno.ejecutar(parametro);
     }
     if (this.cuantos() == 43 & this.ordenEnAulaLlena != null)
     {
         this.ordenEnAulaLlena.ejecutar();
     }
 }
Exemplo n.º 28
0
        public static void informar(Coleccionable <Comparable> coleccionable, int queComparable)
        {
            Console.WriteLine("----------INFORMAR----------");
            Console.WriteLine("La {0} posee {1} elementos.", coleccionable.ToString(), coleccionable.cuantos());
            Console.WriteLine("Minimo >> " + (coleccionable.minimo()));
            Console.WriteLine("Maximo >> " + (coleccionable.maximo()));
            Comparable comparable = FabricaDeComparables.crearPorTeclado(queComparable);

            if (coleccionable.contiene(comparable))
            {
                Console.WriteLine("El elemento leído está en la colección");
            }
            else
            {
                Console.WriteLine("El elemento leído NO está en la colección");
            }
        }        //E6
Exemplo n.º 29
0
        private static void Main(string[] args)
        {
            Console.WriteLine("F0.Common");
            Console.WriteLine();

            int integer = GetInteger(args);

            Console.WriteLine($"{nameof(integer)} {integer} is {(Parity.IsEven(integer) ? "" : "not ")}even.");
            Console.WriteLine($"{nameof(integer)} {integer} is {(Parity.IsOdd(integer) ? "" : "not ")}odd.");
            Console.WriteLine();

            const int min = -240;
            const int max = +240;

            Console.WriteLine($"{nameof(integer)} {integer} clamped to the inclusive range of {min} and {max}:");
            Console.WriteLine(Comparable.Clamp(integer, min, max));
        }
Exemplo n.º 30
0
        static void informar(Coleccionable parametro, int opcion)
        {
            Console.WriteLine("Cantidad de elementos en el coleccionable: {0}", parametro.cuantos());
            Console.WriteLine("Elemento mínimo en el coleccionable: {0}", parametro.minimo());
            Console.WriteLine("Elemento máximo en el coleccionable: {0}{1}", parametro.maximo(), "\n");

            Comparable comparable = Fabrica.crearPorTeclado(opcion);

            if (parametro.contiene(comparable))
            {
                Console.WriteLine("\nEl elemento leido está en la colección.");
            }
            else
            {
                Console.WriteLine("\nEl elemento leido no está en la colección.");
            }
        }
Exemplo n.º 31
0
    // quicksort the subarray a[lo .. hi] using 3-way partitioning
    private static void sort(Comparable[] a, int lo, int hi) { 
        if (hi <= lo) return;
        int lt = lo, gt = hi;
        Comparable v = a[lo];
        int i = lo + 1;
        while (i <= gt) {
            int cmp = a[i].compareTo(v);
            if      (cmp < 0) exch(a, lt++, i++);
            else if (cmp > 0) exch(a, i, gt--);
            else              i++;
        }

        // a[lo..lt-1] < v = a[lt..gt] < a[gt+1..hi]. 
        sort(a, lo, lt-1);
        sort(a, gt+1, hi);
        assert isSorted(a, lo, hi);
    }