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
| protocol LinkedList { | |
| associatedtype Node: Equatable // Associated type | |
| //Associated Types with a Generic Where Clause for iterator | |
| associatedtype Iterator: IteratorProtocol where Iterator.Element == Node | |
| var root: Node { get set } | |
| func append(element: Node) | |
| func printDescription() | |
| func findNode(node: Node) -> Bool |
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
| extension ListNode where NodeValue: CustomStringConvertible { | |
| func printDescription() { | |
| print("ListNode: " + value.description) | |
| } | |
| } | |
| //We can now create instance and call the method “printDescription()”. | |
| let intListNode1 = ListNode<Int>(value: 10) | |
| intListNode1.printDescription() //prints “ListNode: 10” |
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 ListNode<NodeValue>: Equatable where NodeValue: Equatable { | |
| private let value: NodeValue | |
| var next: ListNode? | |
| init(value: NodeValue) { | |
| self.value = value | |
| self.next = nil | |
| } | |
| static func == (lhs: ListNode<NodeValue>, rhs: ListNode<NodeValue>) -> Bool { |
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 ListNode<NodeValue> { | |
| private let value: NodeValue | |
| var next: ListNode? | |
| init(value: NodeValue) { | |
| self.value = value | |
| self.next = nil | |
| } | |
| } |
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 getReverseArray<Element: Equatable>(_ arr: [Element], val: Element) -> [Element] { | |
| return (arr.reversed()).filter{ $0 != val} | |
| } | |
| let intArray = [1, 2, 3, 4] | |
| let reverseArray = getReverseArray(intArr, val: 1) |
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 getReverse<Element>(of arr: [Element]) -> [Element] { | |
| return arr.reversed() | |
| } | |
| let intArr = [1, 2, 3, 4] | |
| let reversedIntArr = getReverse(of: intArr) | |
| print(reversedIntArr) //prints [4, 3, 2, 1] |
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 getReverse(of arr: [String]) -> [String] { | |
| return arr.reversed() | |
| } |
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 getReverse(of arr: [Int]) -> [Int] { | |
| return arr.reversed() | |
| } |
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 IntentViewController: UIViewController, INUIHostedViewControlling { | |
| var computedHeight: CGFloat = 0 | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view. | |
| } | |
| // MARK: - INUIHostedViewControlling | |
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 IntentHandler: INExtension { | |
| override func handler(for intent: INIntent) -> Any { | |
| guard let createExpenseIntent = intent as? CreateExpenseIntent else { | |
| fatalError("Unhandled intent type: \(intent)") | |
| } | |
| let expenseRecord = CreateExpenseIntentHandler.expense(for: createExpenseIntent) | |
| return CreateExpenseIntentHandler(currentExpense: expenseRecord) | |
| } | |
| } |
NewerOlder