初級代碼游戲的專欄介紹與文章目錄-CSDN博客
我的github:codetoys,所有代碼都將會位于ctfc庫中。已經放入庫中我會指出在庫中的位置。
這些代碼大部分以Linux為目標但部分代碼是純C++的,可以在任何平臺上使用。
源碼指引:github源碼指引_初級代碼游戲的博客-CSDN博客
C#是我多年以來的業余愛好,新搞的東西能用C#的就用C#了。
? ? ? ? Array 數組,可重復
? ? ? ? Set 不可重復,無序
? ? ? ? Dictionary 不可重復,鍵值對,無序
? ? ? ? Set和Dictionary估計是使用Hash實現的。
目錄
一、Array
二、Set
三、Dictionary
一、Array
?? ?構造 [類型或初值] Array<類型>(初值)
?? ?+ 數組可以直接相加
?? ?count
?? ?isEmpty
?? ?[2...5] 區間
?? ?first last 注意是?
?? ?append insert remove removeFirst removeLast removeSubrange replaceSubrange removeAll
?? ?contains 是否包含某個元素
?? ?indices 返回Range,下標范圍[startIndex,endIndex)
?? ?min max 不需要預先排序
?? ?sorted 排序,返回排序結果,不改變自身順序
二、Set
?? ?無序集合 可以用數組構造
?? ?可按下標操作 startIndex index() 只能向后移動
?? ?count
?? ?isEmpty
?? ?contains
?? ?min max
?? ?insert remove removeFirst removeAll
?? ?intersection(b) 交集 共同部分
?? ?symmetricDifference(b) 交集的補集 并集去掉共同部分
?? ?union(b) 并集
?? ?subtracting(b) 補集 去掉b也有的部分
?? ?== 全相同
?? ?isSubset 子集
?? ?isSuperset 超集
?? ?isStrictSubset isStrictSuperset 真子集 真超集
?? ?sorted 排序,返回值是數組,不改變自身
三、Dictionary
?? ?聲明 var dict:[type1:type2] var dict:Dictionary<type1,type2>
?? ?初始化 =[ : , :]
?? ?[] = 插入或更新
?? ?updateValue() 不存在返回nil
?? ?removeValue
?? ?removeAll
?? ?sorted 排序,返回值是數組,不改變自身
(這里是文檔結束)
?