예제 #1
0
        //TODO FIX THIS MONSTROSITY
        public TValue this[TKey key]
        {
            get
            {
                if (!Tree.Contains(new ComparableKeyValuePair <TKey, TValue>(key, default(TValue))))
                {
                    throw new KeyNotFoundException();
                }

                var pair = Tree.Find(new ComparableKeyValuePair <TKey, TValue>(key, default(TValue)));

                return(pair.Value);
            }
            set
            {
                var defaultItem = new ComparableKeyValuePair <TKey, TValue>(key, value);
                if (!Tree.Contains(defaultItem))
                {
                    Tree.Insert(defaultItem);
                }
                else
                {
                    var node = Tree.Find(defaultItem);

                    node.Value = value;
                }
            }
        }
예제 #2
0
 public int CompareTo(ComparableKeyValuePair <TKey, TValue> other)
 {
     return(Key.CompareTo(other.Key));
 }
예제 #3
0
        public bool ContainsKey(TKey key)
        {
            var defaultItem = new ComparableKeyValuePair <TKey, TValue>(key, default(TValue));

            return(Tree.Contains(defaultItem));
        }