zoukankan      html  css  js  c++  java
  • [Tip: dotNet collection]Dictionary Data Sequence

    Dictionary:

    For purposes of enumeration, each item in the dictionary is treated as a KeyValuePair<TKey, TValue> structure representing a value and its key. The order in which the items are returned is undefined. [From MSDN]

    While, some insight look extracted from here:

    Dictionary 内的元素有按照先后插入顺序排列的特性. 区别于 Hashtable 及 HashMap 的离散型.

    由于 Hashtable 和 Dictionary 同时存在, 在使用场景上必然存在选择性, 并不任何时刻都能相互替代.
    [1] 单线程程序中推荐使用 Dictionary, 有泛型优势, 且读取速度较快, 容量利用更充分.
    [2] 多线程程序中推荐使用 Hashtable, 默认的 Hashtable 允许单线程写入, 多线程读取, 对 Hashtable 进一步调用 Synchronized() 方法可以获得完全线程安全的类型. 而 Dictionary 非线程安全, 必须人为使用 lock 语句进行保护, 效率大减.
    [3] Dictionary 有按插入顺序排列数据的特性 (注: 但当调用 Remove() 删除过节点后顺序被打乱), 因此在需要体现顺序的情境中使用 Dictionary 能获得一定方便. 

  • 相关阅读:
    nginx
    spring 学习
    mysql 免安装 操作
    院感干预 报错
    iis 无法绑定 net.tcp
    wangEditor 自定义 菜单
    院感干预 发布
    第17篇 shell编程基础(2)
    第16篇 Shell脚本基础(一)
    第15篇 PSR-04 规范
  • 原文地址:https://www.cnblogs.com/taoxu0903/p/1728739.html
Copyright © 2011-2022 走看看