Skip to content

Instantly share code, notes, and snippets.

@jeremycochoy
Created May 23, 2019 22:21
Show Gist options
  • Save jeremycochoy/75dbc0d3395c467855cba1229c53b85a to your computer and use it in GitHub Desktop.
Save jeremycochoy/75dbc0d3395c467855cba1229c53b85a to your computer and use it in GitHub Desktop.
/// Insert a new track
mutating func insert(element: T) {
if let c = cursor {leftList.append(c)}
cursor = element
}
/// Remove the current pointed track
mutating func remove() {
guard let _ = cursor else {return}
if leftList.isNotEmpty {
cursor = leftList.popLast()
} else {
cursor = rightList.popLast()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment