Skip to content

Commit

Permalink
Add Node to seperate class
Browse files Browse the repository at this point in the history
See commit: aecf003
  • Loading branch information
wax911 committed Jun 18, 2020
1 parent aecf003 commit 56d3acf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions emojify/src/main/java/io/wax911/emojify/util/tree/Node.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.wax911.emojify.util.tree

import io.wax911.emojify.model.Emoji
import java.util.HashMap

/**
* Node representation of an emoji tree
*
* @see io.wax911.emojify.util.EmojiTree
*/
class Node {
private val children = HashMap<Char, Node>()

internal var emoji: Emoji? = null

internal val isEndOfEmoji: Boolean
get() = emoji != null

internal fun hasChild(child: Char): Boolean {
return children.containsKey(child)
}

internal fun addChild(child: Char) {
children[child] = Node()
}

internal fun getChild(child: Char): Node? {
return children[child]
}
}

0 comments on commit 56d3acf

Please sign in to comment.