c # custom on the Dictionary Key

Dictionary Dictionary be O (1) lookup data collision will conduct Resize automatically after a certain number of times Hash, also will conduct Resize automatically when insufficient size of the array by Hash bucket algorithm.

 

Dictionary initialization configuration corresponding to the time required Comparer.

 

If no incoming Comparer time, Comparer automatically created based on Key type.

 

Wherein insertion, search and other operations when, by calling the GetHashCode Comparer and Equal method corresponding to the tub to check whether there is a corresponding Key.

 

If no custom Key override GetHashCode and Equal method, the method will call the base class Object.

1, if Key is a struct custom words, boxing operation occurs resulting in GC Alloc. (Older versions of Unity support for C # is not high, so the default comparer no enum processing, resulting in enum as Key can also cause GC)

2, resulting in two identical data objects determined not equal.

 

Guess you like

Origin www.cnblogs.com/smallrainf/p/11666056.html