-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathmain.swift
50 lines (39 loc) · 1.11 KB
/
main.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// main.swift
// Array
//
// Created by ggl on 2019/3/20.
// Copyright © 2019年 ggl. All rights reserved.
//
import Foundation
print("==================动态扩容数组===================")
var array = DynamicExpansionArray(capcity: 10)
for i in 1..<20 {
array.add(num: i)
}
array.print()
array.insert(num: 30, at: 25)
array.print()
array.insert(num: 31, at: 2)
array.print()
array.remove(at: 1)
array.print()
print("\n=================动态扩容集合Set====================")
var set = DynamicExpansionSet<Int>(capacity: 10)
print("======添加1~20数字======")
for i in 1...20 {
set.add(i)
}
set.print()
print("=====是否包含15=======")
print("\(set.contain(15))")
print("=======删除15======")
set.remove(15)
set.print()
print("\n=================合并两个有序数组====================")
let array1 = [1, 8, 9, 10, 14]
let array2 = [4, 9, 13, 20, 25]
let count = array1.count + array2.count
let sortedArray = mergeTwoSortedArray(arrOne: array1, arrOneCount: array1.count, arrTwo: array2, arrTwoCount: array2.count)
printArray(arr: sortedArray, count: count)
sortedArray.deallocate()