The Labs \ Source Viewer \ SSCLI \ System.Collections \ IDictionaryEnumerator

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Interface:  IDictionaryEnumerator
  18. **
  19. **
  20. ** Purpose: Base interface for dictionary enumerators.
  21. **
  22. **
  23. ===========================================================*/
  24. namespace System.Collections
  25. {
  26.     // Interfaces are not serializable
  27.    
  28.     using System;
  29.     // This interface represents an enumerator that allows sequential access to the
  30.     // elements of a dictionary. Upon creation, an enumerator is conceptually
  31.     // positioned before the first element of the enumeration. The first call to the
  32.     // MoveNext method brings the first element of the enumeration into view,
  33.     // and each successive call to MoveNext brings the next element into
  34.     // view until MoveNext returns false, indicating that there are no more
  35.     // elements to enumerate. Following each call to MoveNext, the
  36.     // Key and Value methods are used to obtain the key and
  37.     // value of the element currently in view. The values returned by calls to
  38.     // Key and Value are undefined before the first call to
  39.     // MoveNext and following a call to MoveNext that returned false.
  40.     // Enumerators are typically used in while loops of the form
  41.     //
  42.     // IDictionaryEnumerator e = ...;
  43.     // while (e.MoveNext()) {
  44.     // Object key = e.Key;
  45.     // Object value = e.Value;
  46.     // ...
  47.     // }
  48.     //
  49.     // The IDictionaryEnumerator interface extends the IEnumerator
  50.     // inerface and can thus be used as a regular enumerator. The Current
  51.     // method of an IDictionaryEnumerator returns a DictionaryEntry containing
  52.     // the current key and value pair. However, the GetEntry method will
  53.     // return the same DictionaryEntry and avoids boxing the DictionaryEntry (boxing
  54.     // is somewhat expensive).
  55.     //
  56.     [System.Runtime.InteropServices.ComVisible(true)]
  57.     public interface IDictionaryEnumerator : IEnumerator
  58.     {
  59.         // Returns the key of the current element of the enumeration. The returned
  60.         // value is undefined before the first call to GetNext and following
  61.         // a call to GetNext that returned false. Multiple calls to
  62.         // GetKey with no intervening calls to GetNext will return
  63.         // the same object.
  64.         //
  65.         object Key {
  66.             get;
  67.         }
  68.        
  69.         // Returns the value of the current element of the enumeration. The
  70.         // returned value is undefined before the first call to GetNext and
  71.         // following a call to GetNext that returned false. Multiple calls
  72.         // to GetValue with no intervening calls to GetNext will
  73.         // return the same object.
  74.         //
  75.         object Value {
  76.             get;
  77.         }
  78.        
  79.         // GetBlock will copy dictionary values into the given Array. It will either
  80.         // fill up the array, or if there aren't enough elements, it will
  81.         // copy as much as possible into the Array. The number of elements
  82.         // copied is returned.
  83.         //
  84.         DictionaryEntry Entry {
  85.             get;
  86.         }
  87.     }
  88. }

Developer Fusion