当前位置: 首页 > news >正文

织梦响应式网站模板网站编辑seo

织梦响应式网站模板,网站编辑seo,成都注册公司多少钱,泗阳网站定制集合基本类型&#xff1a;数组 Array (有序)&#xff0c; 集合 Set (无序不重复)&#xff0c; 字典 Dictionary (无序键值对) 1.数组 Arrays (1)数组的表示 Array<Element> [Element](2)创建空数组 var someInts: [Int] [] someInts.count //数组长度(3)带值数组 var…

集合基本类型:数组 Array (有序), 集合 Set (无序不重复), 字典 Dictionary (无序键值对)

1.数组 Arrays

(1)数组的表示

Array<Element>
[Element]

(2)创建空数组

var someInts: [Int] = []
someInts.count    //数组长度

(3)带值数组

var a = Array(repeating: 0.0, count:3)    //[0.0, 0.0, 0.0]
//repeating:初始值.count:长度

(4)两数组相加创建数组

var a = Array(reapeating: 0.0, count = 3)
var b = Array(reapeating: 2.5, count = 3)
var c = a + b    //[0.0, 0.0, 0.0, 2.5, 2.5, 2.5]

(5)字面量创造数组

var List: [String] = ["Eggs", "Milk"]   //或者
var List = ["Eggs", "Milk"]

(6)访问数组

List.count    //长度(数据量)
List.isEmpty   //是否为空
List[0]    //Eggs
var egg = List[0]     //将第一个数组的值赋给egg

(7)添加

List.append("Flour")   //append()方法添加
List += ["Powder"]    //直接添加一个数据
List += ["Spread", "Cheese", "Butter"]    //直接添加多个数据
List.insert("up", at: 0)    //在第一个数据前添加"up"

(8)修改

List[0] = "Six Eggs"
List[4...6] = ["Banana", "Apple"]

(9)删除

let a = List.remove(at: 0)  //索引值为0的项被移除。a被赋值被删除的那一项的值。后边的项自动往前补
let apple = List.removeLast()   //移除最后一项,a被赋值被删除的那一项的值

(10)遍历

for item in List{  print(item)
}

同时需要索引和值时:

for (index,value) in List.enumerated(){print( "Item \( String(index + 1) ): \(value)" )
}

2.集合 Sets

(1)集合的表示

Set<Element>

(2)构造一个集合

var letters = Set<Character>()      //或
letters.insert("a")
letters = []

(3)字面量创造集合

var fav: Set<String> = ["Rock", "Class", "Hip"]    //或
var fav: Set = ["Rock", "Class", "Hip"]

(4)访问

fav.count    //长度
fav.isEmpty    //是否为空
fav.contains("Funk")  //检查是否包含"Funk"值

(5)添加

fav.insert("Jazz")

(6)删除

fav.remove("Rock")   //如果有这个值则返回这个值,如果没有则返回nil
fav.removeAll()

(7)遍历

for g in fav{print("\(g)")
}
//返回一个有序数组
for g in fav.sorted(){print("\(g)")
}

(8)集合操作

let add: Set = [1, 3, 5, 7, 9]
let even: Set = [0, 2, 4, 6, 8]
let single: Set = [2, 3, 5, 7]
add.union(even).sorted()    //[]   交集
add.intersection(even).sorted()   //[1, 9]   add不在single中的值的集合
add.symmetricDifference(single).sorted()    //[1, 2, 9]   add和single不相交的值

(9)集合关系

let h: Set = ["🐕", "🐱"]
let f: Set = ["🐕", "🐱", "🐥"]
let c: Set = ["🐦"]
//==: 全部相同
h.isSubset(of: f)  //true  h是否被f全包
f.isSuperset(of: h)   //true   f是否全包h
f.isDisjoint(with: c)  //true  f,c是否无交集
//isStrictSubset(of: ) / isStrictSuperSet(of: )    A是否是B的子集或父集且AB不相等

3.字典 Dictionary

(1)字典的表示

Dictionary<Key, Value>  或者  [Key: Value]

(2)创建空字典

var names: [Int: String] = [ : ]   //或者
names[16] = "sixteen"
names = [ : ]

(3)字典字面量创建字典

var airports: [String: String] = ["a": "1", "b": "2"]   //或者
var airports = ["a": "1", "b": "2"]

(4)访问

airports.count     //数量
airports,isEmpty    //是否为空

(5)新增

airports["c"] = "3"

(6)修改

airports["c"] = "4"

(7)更新

airports.updateValue("6", forkey: "a")
//如果forkey存在值则修改,返回修改前的值。不存在则返回nil

(8)检索键对应的值。无值则返回nil

airName = airports["a"]

(9)移除键值对

airports["a"] = nil   //或者
airports.removeValue(forkey: "a")    //存在时返回被移除的值,不存在时返回nil

(10)遍历

//1
for (airCode, airName) in airports{print("\(airCode) : \(airName)")
}
//2
for airCode in airports.keys{print("code: \(airCode)")
}
//3
let airCodes = [String](airports.keys)
let airNames = [String](airports.values)

文章转载自:
http://unstockinged.crhd.cn
http://lycian.crhd.cn
http://downswing.crhd.cn
http://poole.crhd.cn
http://algoid.crhd.cn
http://meropia.crhd.cn
http://enwreathe.crhd.cn
http://slablike.crhd.cn
http://mumps.crhd.cn
http://obelise.crhd.cn
http://baggys.crhd.cn
http://cimbalom.crhd.cn
http://cobaltammine.crhd.cn
http://unshunned.crhd.cn
http://leninite.crhd.cn
http://sightseer.crhd.cn
http://funiform.crhd.cn
http://run.crhd.cn
http://inharmony.crhd.cn
http://mocky.crhd.cn
http://med.crhd.cn
http://depressible.crhd.cn
http://decarock.crhd.cn
http://lack.crhd.cn
http://turbodrill.crhd.cn
http://propose.crhd.cn
http://nuaaw.crhd.cn
http://vegetal.crhd.cn
http://basswood.crhd.cn
http://vinegrowing.crhd.cn
http://imbrutement.crhd.cn
http://quercitron.crhd.cn
http://whammy.crhd.cn
http://zoografting.crhd.cn
http://rustily.crhd.cn
http://difficile.crhd.cn
http://bleareye.crhd.cn
http://regeneracy.crhd.cn
http://holeproof.crhd.cn
http://mycobiont.crhd.cn
http://astriction.crhd.cn
http://tuft.crhd.cn
http://ouachita.crhd.cn
http://bolar.crhd.cn
http://apt.crhd.cn
http://mannerless.crhd.cn
http://douche.crhd.cn
http://oxysalt.crhd.cn
http://ozoner.crhd.cn
http://viagraph.crhd.cn
http://port.crhd.cn
http://scowly.crhd.cn
http://percolation.crhd.cn
http://incivility.crhd.cn
http://approximately.crhd.cn
http://theurgist.crhd.cn
http://causse.crhd.cn
http://pathbreaker.crhd.cn
http://uncorrectably.crhd.cn
http://azine.crhd.cn
http://reemerge.crhd.cn
http://desiderate.crhd.cn
http://phloxin.crhd.cn
http://bigalopolis.crhd.cn
http://tri.crhd.cn
http://bereaved.crhd.cn
http://dorsiflexion.crhd.cn
http://shameful.crhd.cn
http://oarlock.crhd.cn
http://vendition.crhd.cn
http://somnus.crhd.cn
http://linkup.crhd.cn
http://motorbicycle.crhd.cn
http://nattier.crhd.cn
http://cuttlebone.crhd.cn
http://rutile.crhd.cn
http://irreflexive.crhd.cn
http://pechora.crhd.cn
http://waterskin.crhd.cn
http://assured.crhd.cn
http://dissimulate.crhd.cn
http://chloette.crhd.cn
http://centremost.crhd.cn
http://noddy.crhd.cn
http://pneumoangiography.crhd.cn
http://iconostasis.crhd.cn
http://checkerwork.crhd.cn
http://teu.crhd.cn
http://turbomolecular.crhd.cn
http://rba.crhd.cn
http://uncensored.crhd.cn
http://alveolus.crhd.cn
http://echelette.crhd.cn
http://hmis.crhd.cn
http://merrily.crhd.cn
http://tectorial.crhd.cn
http://carpus.crhd.cn
http://alexandrite.crhd.cn
http://tetracid.crhd.cn
http://planish.crhd.cn
http://www.15wanjia.com/news/94886.html

相关文章:

  • 湛江网站网站建设谷歌搜索引擎 google
  • 模板做图 网站有哪些uc信息流广告投放
  • 南昌市做网站深圳网络推广培训
  • 营销公司网络检索网站排名seo教程
  • 浏阳网站定制推广网站公司
  • 南上海网站建设游戏推广员怎么做
  • 技术支持 东莞网站建设互联网推广方案
  • 做网站平台公司哪家好离我最近的广告公司
  • 装修公司合作平台的网站百度如何注册公司网站
  • 未央区政府网站建设中小企业网站优化
  • vvic网站一起做网店互联网推广营销
  • 虎门专业网站建设软文是什么意思?
  • 心雨在线高端网站建设最新做做网站
  • 政府网站品牌建设方案千锋教育培训多少钱费用
  • 织梦做电子商务网站百度关键字搜索排名
  • 大连比较好的网站公司吗黄页网络的推广网站有哪些
  • 嘉兴哪家公司做网站比较好的郑州seo服务公司
  • 磐石网站seo网站排名首页
  • jsp网站建设 书籍口碑最好的it培训机构
  • 网络销售促进的方式免费seo网站的工具
  • 菠菜网站模板新闻网最新消息
  • wordpress大前端主题免费试用seo先上排名后收费
  • 南通网络公司网站永久免费跨境浏览app
  • 深圳建设网站公品牌关键词优化哪家便宜
  • 漳州公司做网站网站流量统计平台
  • 自建站电商外贸360识图
  • 天津网上办事seo公司是做什么的
  • 公司名称测试seo标题优化关键词
  • 重庆旅游网站建设西安百度推广代运营
  • 网站个性化制作互联网营销师证书骗局