GOA - System.Collections.Specialized.HybridDictionary

HybridDictionary Class


Implements IDictionary by using a ListDictionary while the collection is small, and then switching to a Hashtable when the collection gets large.

Definition

public class HybridDictionary: Object, IDictionary, ICollection, IEnumerable

Members Table

MethodDescription
AddAdds an entry with the specified key and value into the HybridDictionary.
ClearRemoves all entries from the HybridDictionary.
ContainsDetermines whether the HybridDictionary contains a specific key.
CopyToCopies the HybridDictionary entries to a one-dimensional Array instance at the specified index.
EqualsOverloaded. Compares two objects to determine if they are equal. (Inherited from Object)
GetEnumeratorOverloaded.
GetHashCodeServes as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object)
GetTypeGets the Type of the current instance. (Inherited from Object)
HybridDictionaryOverloaded. Initializes a new instance of HybridDictionary.
ReferenceEqualsDetermines whether the specified Object instances are the same instance. (Inherited from Object)
RemoveRemoves the entry at the specified key from the HybridDictionary.
System.Collections.IEnumerable.GetEnumeratorReturns an IEnumerator that can iterate through the HybridDictionary.
ToStringReturns a String that represents the current Object. (Inherited from Object)
this[]Gets or sets the value associated with the specified key.
PropertyDescription
CountGets the number of key-and-value pairs contained in the HybridDictionary.
IsFixedSizeGets a value indicating whether the HybridDictionary has a fixed size.
IsReadOnlyGets a value indicating whether the HybridDictionary is read-only.
IsSynchronizedGets a value indicating whether access to the HybridDictionary is synchronized.
KeysGets an ICollection containing the keys in the HybridDictionary.
SyncRootGets an object that can be used to synchronize access to the HybridDictionary.
ValuesGets an ICollection containing the values in the HybridDictionary.

Inheritance Hierarchy

Object
HybridDictionary

Examples

// This sample shows how to implement the HybridDictionary class. It also shows how to use the Add and CopyTo methods.

 

using System.Diagnostics;

using System.Collections;

using System.Collections.Specialized;

 

public class SampleHybridDictionary

{

     static void Main()

     {

          // Creates a new HybridDictionary.

          HybridDictionary myHybridDict = new HybridDictionary();

          string[] targetArray = new string[6];

 

          // Adds the new entries to the HybridDictionary.

          myHybridDict.Add(1,"January");

          myHybridDict.Add(2,"February");

          myHybridDict.Add(3,"March");

          myHybridDict.Add(4,"April");

          myHybridDict.Add(5,"May");

          myHybridDict.Add(6,"June");

 

          // Displaying.

          Debug.WriteLine("Before copying");

          Debug.Write("\tThe targetArray: "); DisplayArray(targetArray);

          Debug.WriteLine("\n\t" + "KEY \tVALUE"); DisplayHybridDict(myHybridDict);

 

          // Copies the values of the HDictionary to an array.

          myHybridDict.Values.CopyTo(targetArray, 0);

 

          // Displaying.

          Debug.WriteLine("\nAfter copying");

          Debug.Write("\tThe targetArray: "); DisplayArray(targetArray);

          Debug.WriteLine("\n\t" + "KEY \tVALUE"); DisplayHybridDict(myHybridDict);

     }

 

     static void DisplayArray(string[] myArray)

     {

          for(int i = 0; i < myArray.Length; i++)

            Debug.Write("\t" + myArray[i]);

     }

     static void DisplayHybridDict(IDictionary myDict)

     {

          IDictionaryEnumerator myIDE = myDict.GetEnumerator();

          while(myIDE.MoveNext())

          Debug.WriteLine("\t" + myIDE.Key + "\t\t" + myIDE.Value);

     }

}

 

/*

The output of the sample.

 

Before copying

     The targetArray: null null null null null null

     KEY    VALUE

     1      January

     2      February

     3      March

     4      April

     5      May

     6      June

 

After copying

     The targetArray: January February March April May June

     KEY    VALUE

     1      January

     2      February

     3      March

     4      April

     5      May

     6      June

*/

Class Information

NamespaceSystem.Collections.Specialized
Flash LibrarySystem.scl
Flash Library Version2.0.0.1308
Silverlight LibrarySystem.Windows.Forms.dll



© 2003-2007 NETiKA Technologies. All rights reserved.