erlang 資料結構--(ord)dict_erlang

來源:互聯網
上載者:User
1. 今天是dict 和 orddict 都是key-value 資料機構 dict 判斷key是否等於用的是 =:=,也就是說1,1.0 是不同的key,而orddict判斷等於用的是 == orddict 在learnyousomeerlang 上說的是適用於75個元素以下的資料量, 在之上可以用dict,或者gb_tree 兩個模組提供了相同的功能函數, 所以一起介紹。 2. 函數 值得注意的是append/3 和 append_list/3函數
1> D1 = orddict:store(1, a, orddict:new()).
[{1,a}]
2> D2 = orddict:store(1, [a], orddict:new()).
[{1,[a]}]
3> orddict:append(1, b, D1).
** exception error: bad argument
in operator ++/2
called as a ++ [b]
in call from orddict:append/3 (orddict.erl, line 130)
4> D3 = orddict:append(1, b, D2).
[{1,[a,b]}]
5> orddict:append_list(1, [a,b,c], D3).
[{1,[a,b,a,b,c]}]
函數是將增加的元素以 ++ 的形式加入的, 所以之前在其中的元素必須是個列表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.