Data Structures

发布时间:2017-2-26 2:22:39 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"Data Structures",主要涉及到Data Structures方面的内容,对于Data Structures感兴趣的同学可以参考一下。

Hash Tables哈希表Hash tables are an important exception to all the suggestions above. You cannot initialize an empty hash-table using var aHash: Hash; . You must use var aHash = {}; to initialize a hash table.Significant functions/methods of the hash table:Count An integer number of elements in the hash table.Keys A collection (list-like data structure) of the keys in the hash table.Contains(aKey) Is aKey a key in the hash table?Remove(aKey) Removes a key/value pair.Add(aKey, aValue) Equivalent to aHash[aKey] = aValue;ArrayLists动态列表You might be tempted to use new Array(); for your arrays. While this is understandable, the Array implementation has some significant limits, notably not supporting the indexOf method. The ArrayList has many of the convenience methods one might want. Warnings:You cannot create a null ArrayList using var someArray: ArrayList; and subsequently access that ArrayList's members without first creating it. Workaround: in your Awake function, do var someArray = new ArrayList();You cannot access the ArrayList constructor - var someArray = new ArrayList(foo, bar, baz); doesn't work. Workaround:You must create the ArrayList and subsequently populate it.Significant functions/methods of the array list:Count An integer number of elements in the array. Use this instead of length. e.g. for (i=0; i < anArrayList.Count; i++) { ... }Contains(anObject) Is aMember an element in the hash table? e.g. if (anArrayList.Contains(anObject)) { ... }.Remove(aMember) Removes aMember. Does not raise an error if aMember doesn't exist in the array.Add(anObject) Equivalent to anArray[] = aMember; except that anArray.Add(anObject) works.

上一篇:【转】用 Unity 做 iPhone 游戏之代码优化个人总结
下一篇:希尔排序

相关文章

关键词: Data Structures

相关评论

本站评论功能暂时取消,后续此功能例行通知。

一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!

二、互相尊重,对自己的言论和行为负责。