コード例 #1
0
 public void Add([NotNull] TKey key, [NotNull] TValue value)
 {
     if (!diccionari.ContainsKey(key))
     {
         diccionari.Add(key, new LlistaOrdenada <IComparable, TValue>());
     }
     diccionari[key].Add(value, value);
 }
コード例 #2
0
 static Hex()
 {
     diccionarioCaracteresValidos = new LlistaOrdenada <char, char>();
     for (int i = 0; i < caracteresHex.Length; i++)
     {
         diccionarioCaracteresValidos.Add(caracteresHex[i][0], caracteresHex[i][0]);
     }
 }
コード例 #3
0
        public Point GetPoint(int colorInt)
        {
            const int ARGB = 4;

            int posicion;

            byte[] bytesColor;
            Point  location   = default(Point);
            bool   encontrado = false;

            if (pointLocatedByColorList.ContainsKey(colorInt))
            {
                location = pointLocatedByColorList[colorInt].Value;
            }
            else
            {
                bytesColor = Serializar.GetBytes(colorInt);
                for (int y = 0, yFin = Convert.ToInt32(imagen.Height), xFin = Convert.ToInt32(imagen.Width) * ARGB; y < yFin && !encontrado; y++)
                {
                    for (int x = 0; x < xFin && !encontrado; x += ARGB)
                    {
                        posicion   = x + (y * xFin);
                        encontrado = bytesImg[posicion] == bytesColor[0] && bytesImg[posicion + 1] == bytesColor[1] && bytesImg[posicion + 2] == bytesColor[2] && bytesImg[posicion + 3] == bytesColor[3];
                        if (encontrado)
                        {
                            location = new Point(x, y);
                        }
                    }
                }
                if (!encontrado)
                {
                    throw new ArgumentOutOfRangeException("El color no esta dentro de la imagen!");
                }
                else
                {
                    pointLocatedByColorList.Add(colorInt, location);
                    if (!colorLocatedByPointerList.ContainsKey(new PointZ(location.X, location.Y, 0)))
                    {
                        colorLocatedByPointerList.Add(new PointZ(location.X, location.Y, 0), System.Drawing.Color.FromArgb(colorInt));
                    }
                }
            }
            return(location);
        }
コード例 #4
0
        public void Añadir(Color key, Color value)
        {
            int keyArgb = key.ToArgb();

            if (!diccionario.ContainsKey(keyArgb))
            {
                diccionario.Add(keyArgb, new List <byte[]>());
            }
            diccionario[keyArgb].Value.Add(Serializar.GetBytes(value.ToArgb()));
        }
コード例 #5
0
 public void Add([NotNull] TKey1 key1, [NotNull] TKey2 key2, TValue value)
 {
     if (llista1.ContainsKey(key1))
     {
         throw new Exception("Esta duplicada la clave1 para el valor");
     }
     if (llista2.ContainsKey(key2))
     {
         throw new Exception("Esta duplicada la clave2 para el valor");
     }
     llista1.Add(key1, value);
     llista2.Add(key2, value);
     llistaClau1.Add(key1, key2);
     llistaClau2.Add(key2, key1);
 }