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
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
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] | |
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 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] | |
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
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
yourViewName.addSubview(childView) |
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 viewOne = UIView() | |
let viewTwo = UIView() | |
let viewThree = UIView() | |
viewOne.tag = 1 | |
viewTwo.tag = 2 | |
viewThree.tag = 3 | |
viewOne.addSubview(viewTwo) | |
viewOne.addSubview(viewThree) |
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 viewOne = UIView() | |
let viewTwo = UIView() | |
let viewThree = UIView() | |
viewOne.tag = 1 | |
viewTwo.tag = 2 | |
viewThree.tag = 3 | |
viewOne.addSubview(viewTwo) | |
viewOne.addSubview(viewThree) |