Skip to content

Instantly share code, notes, and snippets.

@GuanshanLiu
Last active September 29, 2018 12:21
Show Gist options
  • Save GuanshanLiu/74bee8d62c8838783599e3578c9fd13d to your computer and use it in GitHub Desktop.
Save GuanshanLiu/74bee8d62c8838783599e3578c9fd13d to your computer and use it in GitHub Desktop.
public var isEmpty: Bool {
return elements.isEmpty
}
public var count: Int {
return elements.count
}
public func leftChildIndex(forParentAt index: Int) -> Int {
return 2 * index + 1
}
public func rightChildIndex(forParentAt index: Int) -> Int {
return 2 * index + 2
}
public func parentIndex(forChildAt index: Int) -> Int {
return (index - 1) / 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment