Ejemplo n.º 1
0
 public NodeEnumerator(ListDictionary list)
 {
     this.list    = list;
     this.version = list.version;
     this.start   = true;
     this.current = null;
 }
Ejemplo n.º 2
0
 /// <summary>Creates an empty <see cref="T:System.Collections.Specialized.ListDictionary" /> using the default comparer.</summary>
 public ListDictionary()
 {
     this.count    = 0;
     this.version  = 0;
     this.comparer = null;
     this.head     = null;
 }
Ejemplo n.º 3
0
 private ListDictionary.DictionaryNode FindEntry(object key, out ListDictionary.DictionaryNode prev)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key", "Attempted lookup for a null key.");
     }
     ListDictionary.DictionaryNode next = this.head;
     prev = null;
     if (this.comparer == null)
     {
         while (next != null)
         {
             if (key.Equals(next.key))
             {
                 break;
             }
             prev = next;
             next = next.next;
         }
     }
     else
     {
         while (next != null)
         {
             if (this.comparer.Compare(key, next.key) == 0)
             {
                 break;
             }
             prev = next;
             next = next.next;
         }
     }
     return(next);
 }
Ejemplo n.º 4
0
 public NodeKeyValueEnumerator(ListDictionary list, bool isKeys)
 {
     this.list    = list;
     this.isKeys  = isKeys;
     this.version = list.version;
     this.start   = true;
     this.current = null;
 }
Ejemplo n.º 5
0
 public void Reset()
 {
     if (this.version != this.list.version)
     {
         throw new InvalidOperationException(SR.GetString("InvalidOperation_EnumFailedVersion"));
     }
     this.start   = true;
     this.current = null;
 }
Ejemplo n.º 6
0
 /// <summary>Adds an entry with the specified key and value into the <see cref="T:System.Collections.Specialized.ListDictionary" />.</summary>
 /// <param name="key">The key of the entry to add. </param>
 /// <param name="value">The value of the entry to add. The value can be null. </param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="key" /> is null. </exception>
 /// <exception cref="T:System.ArgumentException">An entry with the same key already exists in the <see cref="T:System.Collections.Specialized.ListDictionary" />. </exception>
 public void Add(object key, object value)
 {
     ListDictionary.DictionaryNode prev;
     ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key, out prev);
     if (dictionaryNode != null)
     {
         throw new ArgumentException("key", "Duplicate key in add.");
     }
     this.AddImpl(key, value, prev);
 }
Ejemplo n.º 7
0
 public bool MoveNext()
 {
     this.FailFast();
     if (this.current == null && !this.isAtStart)
     {
         return(false);
     }
     this.current   = ((!this.isAtStart) ? this.current.next : this.dict.head);
     this.isAtStart = false;
     return(this.current != null);
 }
Ejemplo n.º 8
0
 private void AddImpl(object key, object value, ListDictionary.DictionaryNode prev)
 {
     if (prev == null)
     {
         this.head = new ListDictionary.DictionaryNode(key, value, this.head);
     }
     else
     {
         prev.next = new ListDictionary.DictionaryNode(key, value, prev.next);
     }
     this.count++;
     this.version++;
 }
Ejemplo n.º 9
0
 void ICollection.CopyTo(Array array, int index)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index", SR.GetString("ArgumentOutOfRange_NeedNonNegNum"));
     }
     for (ListDictionary.DictionaryNode node = this.list.head; node != null; node = node.next)
     {
         array.SetValue(this.isKeys ? node.key : node.value, index);
         index++;
     }
 }
Ejemplo n.º 10
0
 public bool MoveNext()
 {
     if (this.version != this.list.version)
     {
         throw new InvalidOperationException(SR.GetString("InvalidOperation_EnumFailedVersion"));
     }
     if (this.start)
     {
         this.current = this.list.head;
         this.start   = false;
     }
     else if (this.current != null)
     {
         this.current = this.current.next;
     }
     return(this.current != null);
 }
Ejemplo n.º 11
0
 /// <summary>Removes the entry with the specified key from the <see cref="T:System.Collections.Specialized.ListDictionary" />.</summary>
 /// <param name="key">The key of the entry to remove. </param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="key" /> is null. </exception>
 public void Remove(object key)
 {
     ListDictionary.DictionaryNode dictionaryNode2;
     ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key, out dictionaryNode2);
     if (dictionaryNode == null)
     {
         return;
     }
     if (dictionaryNode2 == null)
     {
         this.head = dictionaryNode.next;
     }
     else
     {
         dictionaryNode2.next = dictionaryNode.next;
     }
     dictionaryNode.value = null;
     this.count--;
     this.version++;
 }
Ejemplo n.º 12
0
 /// <summary>Gets or sets the value associated with the specified key.</summary>
 /// <returns>The value associated with the specified key. If the specified key is not found, attempting to get it returns null, and attempting to set it creates a new entry using the specified key.</returns>
 /// <param name="key">The key whose value to get or set. </param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="key" /> is null. </exception>
 public object this[object key]
 {
     get
     {
         ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key);
         return((dictionaryNode != null) ? dictionaryNode.value : null);
     }
     set
     {
         ListDictionary.DictionaryNode prev;
         ListDictionary.DictionaryNode dictionaryNode = this.FindEntry(key, out prev);
         if (dictionaryNode != null)
         {
             dictionaryNode.value = value;
         }
         else
         {
             this.AddImpl(key, value, prev);
         }
     }
 }
 public void Reset()
 {
     if (this.version != this.list.version)
     {
         throw new InvalidOperationException(SR.GetString("InvalidOperation_EnumFailedVersion"));
     }
     this.start = true;
     this.current = null;
 }
 public bool MoveNext()
 {
     if (this.version != this.list.version)
     {
         throw new InvalidOperationException(SR.GetString("InvalidOperation_EnumFailedVersion"));
     }
     if (this.start)
     {
         this.current = this.list.head;
         this.start = false;
     }
     else if (this.current != null)
     {
         this.current = this.current.next;
     }
     return (this.current != null);
 }
 public NodeKeyValueEnumerator(ListDictionary list, bool isKeys)
 {
     this.list = list;
     this.isKeys = isKeys;
     this.version = list.version;
     this.start = true;
     this.current = null;
 }
 public NodeEnumerator(ListDictionary list)
 {
     this.list = list;
     this.version = list.version;
     this.start = true;
     this.current = null;
 }
Ejemplo n.º 17
0
 /// <summary>Removes all entries from the <see cref="T:System.Collections.Specialized.ListDictionary" />.</summary>
 public void Clear()
 {
     this.head  = null;
     this.count = 0;
     this.version++;
 }
Ejemplo n.º 18
0
 public DictionaryNode(object key, object value, ListDictionary.DictionaryNode next)
 {
     this.key   = key;
     this.value = value;
     this.next  = next;
 }
Ejemplo n.º 19
0
 public void Reset()
 {
     this.FailFast();
     this.isAtStart = true;
     this.current   = null;
 }