One, array of arrays changes
Examples of the modified APIs in array arrays are as follows:
Create an array of a large number of the same elements//create arrays of 10 string elements, and each element is a string "Hello"//swift2.2//var array3 = [string] (Count:10, Repeatedvalue: " Hello ")//swift3.0 var array3 = [String] (repeating:" Hello ", count:10)//Create an array of 10 int types of elements, each of which is 1//swift2.2 array 4 = Array (count:10, repeatedvalue:1)//swift3.0 var array4 = Array (repeating:1, count:10) var Array = [1,2,3,4,5,6,7, 8,9]//Append a set of elements to the array//swift2.2//array.appendcontentsof ([11,12,13])//swift3.0 array.append (contentsof: [11,12,13])// Inserts an element to a location in the array//swift2.2//array.insert (0, atindex:0)//swift3.0 array.insert (0, at:0)//Inserts a set of elements into a location in the array//swift2.2/ /array.insertcontentsof ([ -2,-1], at:0)//swift3.0 Array.insert (contentsof: [ -2,-1], at:0)//Remove elements from a location in the divisor group//swift2.2//
Array.removeatindex (1)//swift3.0 array.remove (at:1)//Removing a range of elements//swift2.2//array.removerange (0...2)//swift3.0
Array.removesubrange (0...2)//modify a range of elements//swift2.2//array.replacerange (0...2, with: [0,1])//swift3.0 Array.replacesubrange (0...2, with: [0,1])//Array enumeration traversal will output (0,0) (1,1) (2,2) (3,3) (4,4)//swift3.0 modifies the enumeration property enumerate to enumerated () method for item in arraylet.enumerated () {print (item)} V Ar arraysort = [1,3,5,6,7]//Get the maximum value in the array//swift2.2//arraysort.maxelement ()//swift3.0 Arraysort.max ()//Get the smallest value in the array// swift2.2//arraysort.minelement ()//swift3.0 arraysort.min ()//from large to small sort//swift2.2//arraysort = Arraysort.sort (>)// swift3.0 ArraySort = arraysort.sorted (isorderedbefore: >)//Small to large sort//swift2.2//arraysort = Arraysort.sort (<)//
swift3.0 ArraySort = arraysort.sorted (Isorderedbefore: <)
Ii. changes in Set collections
Examples of modifications in the Set collection are as follows:
Create set set var set1:set<int> = [1,2,3,4]//subscript move//Get a subscript after an element//swlft2.2//set1[set1.startindex.successor ()]// swift3.0 Set1[set1.index (After:set1.startIndex)]//Get a few elements after a subscript//swift2.2//set1[set1.startindex.advancedby (3)]// swift3.0 Set1[set1.index (Set1.startindex, Offsetby:3)]//Get the maximum value in the collection//swift2.2//set1.maxelement ()//swift3.0 Set1.max ()//Gets the minimum value in the collection//swift2.2//set1.minelement ()//swift3.0 set1.min ()//Removes the element//swift2.2//set1.removeatindex of a location in the collection (
Set1.indexof (3)!) swift3.0 Set1.remove (At:set1.index (of:3)!) var set3:set<int> = [1,2,3,4] var set4:set<int> = [1,2,5,6]//return Backcross set {1,2}//swift2.2//var setinter = Set3.intersect (set4)//swift3.0 var setinter = set3.intersection (SET4)//Return the intersection of the complement {3,4 , 5,6}//swift2.2//var Setex = Set3.exclusiveor (set4)//swift3.0 var Setex = set3.symmetricdifference (SET4) var set5:Set = [1,2] var set6:set = [2,3] var set7:set = [1,2,3] var set8:set = [1,2,3]//Determine if a subset of a set SET5 is a subset of the SET7 return ture//swift2.2/ /set5.issubsetof (SET7)//swift3.0 Set5.issubset (OF:SET7)//To determine whether the superset of a set SET7 is a superset of set5 ture//swift2.2 (//set7.issupersetof) set5
Set7.issuperset (OF:SET5)//To determine whether a true subset of a set SET5 is a true subset of Set7 returns ture//swift2.2//set5.isstrictsubsetof (set7)//swift3.0 Set5.isstrictsubset (OF:SET7)//To determine if the true superset of a set SET7 is not set8 true superset returns false//swift2.2//set7.isstrictsupersetof (SET8)//
swift3.0 Set7.isstrictsuperset (OF:SET8)
Iii. changes in the dictionary dictionary
The dictionary dictionary modifies the following example:
To delete a key value by key
//swift2.2
//dic1.removevalueforkey (1)
//swift3.0
dic1.removevalue (forkey:1)