Skip to content

Kotlin huffman #660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Kroppeb
Copy link

@Kroppeb Kroppeb commented Dec 23, 2019

No description provided.

@Gathros
Copy link
Contributor

Gathros commented Dec 25, 2019

This code doesn't work for a string of one unique character multiple times. I don't know Kotlin at all but I have a fix you can look at and improve on.

if (priorityQueue.size == 1) {
    val left = priorityQueue.remove()
    val right = Leaf(0, '\u0000')
    root = Branch(left, right)
} else {
    root = priorityQueue.remove() as? Branch ?: error("No support for string of one unique letter")
}

I'm not sure how to get right to be a null object but this will do.

Signed-off-by: Robbe Pincket <[email protected]>
@berquist
Copy link
Member

I just saw this. Why are these changes on top of #640?

@berquist berquist added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label May 24, 2020
@ntindle
Copy link
Member

ntindle commented Aug 28, 2021

[lang: kotlin]

@github-actions github-actions bot added the lang: kotlin Kotlin programming language label Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) lang: kotlin Kotlin programming language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants