This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var twoDimensionalArray: [[Int]] = [[0, 1], [2, 3]] | |
| for i in 0..<twoDimensionalArray.count { | |
| for n in 0..<twoDimensionalArray[i].count { | |
| print(twoDimensionalArray[i][n]) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arrOne = [1, 2, 3, 4, 5, 6] | |
| for i in arrOne { | |
| print(i) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func remove(node: Node) -> T { | |
| let prev = node.previous | |
| let next = node.next | |
| if let prev = prev { | |
| prev.next = next | |
| } else { | |
| head = next | |
| } | |
| next?.previous = prev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arrOne = [1, 2, 3, 4, 5, 6] | |
| func binarySearch(_ inputArray: [Int], element: Int) -> Int? { | |
| var begin = 0 | |
| var end = inputArray.count | |
| while begin < end { | |
| let mid = begin + (end - begin) / 2 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func append(value: T) { | |
| let newNode = Node(value: value) | |
| if let lastNode = last { | |
| newNode.previous = lastNode | |
| lastNode.next = newNode | |
| } else { | |
| head = newNode | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arrOne = [1, 2, 3, 4, 5, 6] | |
| arrOne[0] | |
| arrOne[2] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class HashElement<T: Hashable, U> { | |
| var key: T | |
| var value: U? | |
| init(key: T, value: U?) { | |
| self.key = key | |
| self.value = value | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| protocol ImageDownloadProtocol { | |
| func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void) | |
| } | |
| extension ImageDownloadProtocol { | |
| func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void) { | |
| let session = URLSession(configuration: .default) | |
| DispatchQueue.global(qos: .background).async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class ViewController: UIViewController { | |
| let viewOne = UIView() | |
| let viewTwo = UIView() | |
| let intermediaryView = UIView() | |
| let viewSuper = UIView() | |
| override func viewDidLoad() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| func insertionSort(values: [Int]) { | |
| var valuesArray = values | |
| for i in 1...valuesArray.count - 1 { | |
| let nextItem = valuesArray[i] | |
| var currentIndex = i - 1 | |
| while currentIndex >= 0 && valuesArray[currentIndex] > nextItem { | |
| valuesArray[currentIndex + 1] = valuesArray[currentIndex] |