This file contains hidden or 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
| $ ./kobaltw test ~/t/wire | |
| __ __ __ __ __ | |
| / //_/ ____ / /_ ____ _ / / / /_ | |
| / ,< / __ \ / __ \ / __ `/ / / / __/ | |
| / /| | / /_/ / / /_/ // /_/ / / / / /_ | |
| /_/ |_| \____/ /_.___/ \__,_/ /_/ \__/ 0.407 | |
| ╔════════════════════════════╗ | |
| ║ Building wire-gson-support ║ | |
| ╚════════════════════════════╝ |
This file contains hidden or 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
| /* | |
| * This file is part of Material Audiobook Player. | |
| * | |
| * Material Audiobook Player is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or any later version. | |
| * | |
| * Material Audiobook Player is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains hidden or 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
| class Node(val value: String, | |
| val children: List<Node> = emptyList()) | |
| fun displayGraph(roots: List<Node>, indent: String = “”) { | |
| roots.forEach { | |
| println(indent + it.value) | |
| displayGraph(it.children, indent + “ “) | |
| } | |
| } |
This file contains hidden or 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
| val node = Node(“Root”, listOf( | |
| Node(“A”, listOf( | |
| Node(“A1”), | |
| Node(“A2”), | |
| Node(“A3”)) | |
| ), | |
| Node(“B”, listOf( | |
| Node(“B1”), | |
| Node(“B2”, listOf( | |
| Node(“B21”), |
This file contains hidden or 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
| interface INode<T> { | |
| val children: List<INode<T>> | |
| val value: T | |
| } |
This file contains hidden or 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
| fun <T> displayGraph(roots: List<INode<T>>, indent: String = “”) { | |
| roots.forEach { | |
| println(indent + it.value) | |
| displayGraph(it.children, indent + “ “) | |
| } | |
| } |
This file contains hidden or 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
| class Node(override val value: String, | |
| override val children: List<Node> = emptyList()) : INode<String> | |
| class Tree(val payload: Int, val leaves: List<Tree>) : INode<Int> { | |
| override val children: List<Tree> = leaves | |
| override val value: Int = payload | |
| } |
This file contains hidden or 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
| class Node(override val value: String, | |
| override val children: List<Node> = emptyList()) : INode<String> | |
| class Tree(val payload: Int, val leaves: List<Tree>) : INode<Int> { | |
| override val children: List<Tree> = leaves | |
| override val value: Int = payload | |
| } |
This file contains hidden or 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
| val graph = listOf(Node(“A”, listOf( | |
| Node(“A1”), | |
| Node(“A2”))) | |
| ) | |
| displayGraph(graph) | |
| val tree = listOf(Tree(1, listOf( | |
| Tree(11), | |
| Tree(12))) | |
| ) |
This file contains hidden or 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
| fun <T, U> displayGraphGeneric(roots: List<T>, | |
| children: (T) -> List<T>, | |
| value: (T) -> U, | |
| indent: String = “”) { | |
| roots.forEach { | |
| println(indent + value(it)) | |
| displayGraphGeneric(children(it), children, value, | |
| indent + “ “) | |
| } | |
| } |
OlderNewer