Пример #1
0
            public bool MoveNext()
            {
                if (version != tree.version)
                {
                    ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumFailedVersion);
                }

                if (stack.Count == 0)
                {
                    current = null;
                    return(false);
                }

                current = stack.Pop();
                TreeSet <T> .Node node = current.Right;
                while (node != null)
                {
                    stack.Push(node);
                    node = node.Left;
                }
                return(true);
            }
        public TValue this[TKey key]
        {
            get
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                TreeSet <KeyValuePair <TKey, TValue> > .Node node = _set.FindNode(new KeyValuePair <TKey, TValue>(key, default(TValue)));
                if (node == null)
                {
                    throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
                }

                return(node.Item.Value);
            }
            set
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                TreeSet <KeyValuePair <TKey, TValue> > .Node node = _set.FindNode(new KeyValuePair <TKey, TValue>(key, default(TValue)));
                if (node == null)
                {
                    _set.Add(new KeyValuePair <TKey, TValue>(key, value));
                }
                else
                {
                    node.Item = new KeyValuePair <TKey, TValue>(node.Item.Key, value);
                    _set.UpdateVersion();
                }
            }
        }
 public SortedDictionary(IComparer <TKey> comparer)
 {
     _set = new TreeSet <KeyValuePair <TKey, TValue> >(new KeyValuePairComparer(comparer));
 }
 internal Enumerator(SortedDictionary <TKey, TValue> dictionary, int getEnumeratorRetType)
 {
     _treeEnum             = dictionary._set.GetEnumerator();
     _getEnumeratorRetType = getEnumeratorRetType;
 }
Пример #5
0
 internal Enumerator(SortedDictionary <TKey, TValue> dictionary)
 {
     _treeEnum = dictionary._set.GetEnumerator();
 }