Ejemplo n.º 1
0
 public override bool Equals(object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (!(o is ArrayMap.Entry))
     {
         return(false);
     }
     ArrayMap.Entry e = (ArrayMap.Entry)o;
     return((Key == null ? e.Key == null : Key.Equals(e.Key)) && (Value == null ? e.Value == null : Value.Equals(e.Value)));
 }
Ejemplo n.º 2
0
 public ArrayMap(K[] keys, V[] values)
 {
     if (keys.Length != values.Length)
     {
         throw new ArgumentException("different number of keys and values.");
     }
     size       = keys.Length;
     capacity   = size;
     entryArray = new ArrayMap.Entry[size];
     for (int i = 0; i < keys.Length; i++)
     {
         entryArray[i] = new ArrayMap.Entry(keys[i], values[i]);
     }
 }
Ejemplo n.º 3
0
 public override V Put(K key, V val)
 {
     for (int i = 0; i < size; i++)
     {
         if (key.Equals(entryArray[i].Key))
         {
             return(entryArray[i].SetValue(val));
         }
     }
     if (capacity <= size)
     {
         Resize();
     }
     entryArray[size] = new ArrayMap.Entry <K, V>(key, val);
     size++;
     return(null);
 }