This file contains 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
final class MoviesSearchViewModel: MoviesSearchViewModelType { | |
private weak var navigator: MoviesSearchNavigator? | |
private let useCase: MoviesUseCaseType | |
private var cancellables: [AnyCancellable] = [] | |
init(useCase: MoviesUseCaseType, navigator: MoviesSearchNavigator) { | |
self.useCase = useCase | |
self.navigator = navigator | |
} |
This file contains 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 Foundation | |
final class FileIO { | |
private let buffer:[UInt8] | |
private var index: Int = 0 | |
init(fileHandle: FileHandle = FileHandle.standardInput) { | |
buffer = Array(try! fileHandle.readToEnd()!)+[UInt8(0)] // 인덱스 범위 넘어가는 것 방지 |
This file contains 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
public struct Heap<T> { | |
var nodes: [T] = [] | |
let comparer: (T,T) -> Bool | |
var isEmpty: Bool { | |
return nodes.isEmpty | |
} | |
init(comparer: @escaping (T,T) -> Bool) { | |
self.comparer = comparer |
This file contains 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 Publisher { | |
func coolDown<S: Scheduler>(for cooltime: S.SchedulerTimeType.Stride, | |
scheduler: S) -> some Publisher<Self.Output, Self.Failure> { | |
return self.receive(on: scheduler) | |
.scan((S.SchedulerTimeType?.none, Self.Output?.none)) { | |
let eventTime = scheduler.now | |
let minimumTolerance = scheduler.minimumTolerance | |
guard let lastSentTime = $0.0 else { | |
return (eventTime, $1) | |
} |