Gauche:Dictionary:OrderedDictionary
yamasushi(2013/04/22 04:09:08 UTC) <ordered-dictionary>についてまとめてみます。
- 関連ファイル
<ordered-dictionary>とはなにか?
- (key,値)のコレクションで、indexによりアクセスできるもの。
なので、<orderd-dictionary>は<sequence>である。- .Netでは → OrderedDictionary Class (System.Collections.Specialized)
http://msdn.microsoft.com/en-us/library/system.collections.specialized.ordereddictionary.aspx
- .Netでは → OrderedDictionary Class (System.Collections.Specialized)
- Python : OrderedDict
http://docs.python.org/2/library/collections.html#collections.OrderedDict
Return an instance of a dict subclass, supporting the usual dict methods. An OrderedDict is a dict that remembers the order that keys were first inserted. If a new entry overwrites an existing entry, the original insertion position is left unchanged. Deleting an entry and reinserting it will move it to the end.
New in version 2.7.
- Racket : Orders and Ordered Dictionaries
http://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html
- この"orderd-dict"は文字通りの順序付きの辞書。
- .Netでは → SortedDictionary(TKey, TValue) Class (System.Collections.Generic)
http://msdn.microsoft.com/en-us/library/f7fta44c.aspx
なにが<ordered-dictionary>ではないか?
- <sequence>は<ordered-dictionary>ではない。
<sequence>はindexをキーにした<dictionary>と見なせるのであるけど、クラス階層が逆立ちしてしまう!!
- yamasushi(2013/05/06 06:40:06 UTC) キーの挿入が他のキー->値対応に影響をあたえるのだから、辞書とはいえない。
ref
- http://chaton.practical-scheme.net/gauche/a/2013/04/21
- kaki
<dictionary> には ref がないんですね.でも <ordered-dictionary> は <sequence> を継承していて <sequence> には ref があるので…と思ったら referencer メソッドが無いと言われてしまった.
<dictionary> は ref で dict-get できればいいような気がします.<hash-table> や <tree-map> でも ref 定義してありますし.
- shiro
<dictionary>にrefがまだ無いのは、ordered-dictionaryでsequenceのrefと意味がかぶるからどうしようかなと思って保留にしてた気がします。
- kaki