Esempio n. 1
0
        /// <summary>
        /// Remove element.
        /// </summary>
        /// <param name="key"></param>
        public void Remove(K key)
        {
            MapKeyValue <K, V> item = m_list[key];

            if (item != null)
            {
                m_list.Remove(item);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Extract value from specified key name.
        /// </summary>
        /// <typeparam name="T">Type that want to extract.</typeparam>
        /// <param name="key">Key.</param>
        /// <returns></returns>
        public T ExtractValue <T>(K key)
        {
            MapKeyValue <K, V> keyVal = this[key];

            if (keyVal == null)
            {
                return(default(T));
            }

            return(keyVal.ConvertValueTo <T>());
        }
Esempio n. 3
0
        /// <summary>
        /// Put key and value into collection. If key has duplicate it will replace value to old key.
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="value">Value</param>
        public void Put(K key, V value)
        {
            MapKeyValue <K, V> newItem = new MapKeyValue <K, V>(key, value);

            MapKeyValue <K, V> item = m_list[key];

            if (item != null)
            {
                m_list.Remove(item);
            }

            m_list.Add(newItem);
        }
Esempio n. 4
0
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. </param><exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception><filterpriority>2</filterpriority>
        public override bool Equals(object obj)
        {
            if (obj is MapKeyValue <K, V> )
            {
                MapKeyValue <K, V> item = obj as MapKeyValue <K, V>;
                if (item.Key.Equals(this.Key) && item.Value.Equals(this.Value))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
 public MapKeyValue <K, V> this[K key]
 {
     get
     {
         for (int i = 0; i < this.Count; i++)
         {
             MapKeyValue <K, V> item = this[i];
             if (item.Key.Equals(key))
             {
                 return(item);
             }
         }
         return(null);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Put key and value into collection. If key has duplicate it will replace value to old key.
 /// </summary>
 /// <param name="item"></param>
 public void Put(MapKeyValue <K, V> item)
 {
     Put(item.Key, item.Value);
 }
Esempio n. 7
0
 /// <summary>
 /// Determines whether the specified item to has key is equals.
 /// </summary>
 /// <param name="item">Item to compare equals.</param>
 /// <returns></returns>
 public bool EqualsKey(MapKeyValue <K, V> item)
 {
     return(item != null && item.Key.Equals(this.Key));
 }