NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Dictionary Constructor (Int32, Single)

Creates a new Dictionary with the specified initial capacity and load factor.

[Visual Basic]
Overloads Public Sub New( _
   ByVal capacity As Integer, _
   ByVal loadFactor As Single _
)
[C#]
public Dictionary(
   int capacity,
   float loadFactor
);
[C++]
public: Dictionary(
   int capacity,
   float loadFactor
);
[JScript]
public function Dictionary(
   capacity : int,
   loadFactor : float
);

Parameters

capacity
The initial number of entries that the Dictionary can contain.
loadFactor
A number in the range from 0.1 through 1.0 indicating the maximum ratio of entries to buckets.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException capacity is less than zero.

-or-

loadfactor is less than 0.1.

-or-

loadfactor is greater than 1.0.

Remarks

Specifying the initial capacity eliminates a number of resizing operations that would otherwise be performed while adding entries to the Dictionary. Capacity is increased as the number of buckets is increased based on the load factor.

The maximum load factor is the maximum ratio of entries to buckets. A smaller load factor means faster lookup at the cost of increased memory consumption. A maximum load factor of 1.0 is the best balance between speed and size.

When the actual load factor reaches the maximum load factor, the number of buckets is automatically increased to the smallest prime number that is larger than twice the current number of buckets.

See Also

Dictionary Class | Dictionary Members | System.Collections Namespace | Dictionary Constructor Overload List