Repository navigation
Installation
Add this package as a dependency in your Package.swift:
dependencies: [
.package(url: "https://github.com/attaswift/BTree.git", from: "4.1.0"),
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "1.3.3"),
.package(url: "https://github.com/DJBen/BTreeCustomDump.git", from: "1.0.0")
]Then add it to your target dependencies:
.target(
name: "YourTarget",
dependencies: [
"BTree",
"BTreeCustomDump",
.product(name: "CustomDump", package: "swift-custom-dump")
]
)Features
- CustomDumpReflectable conformance for
BTree<Key, Value>- displays as clean dictionary format - CustomDumpReflectable conformance for
Map<Key, Value>- displays as clean dictionary format - CustomDumpReflectable conformance for
List<Element>- displays as indexed array - Unit Tests - comprehensive test suite ensuring proper functionality
Usage
Simply import both BTree and BTreeCustomDump in your code:
import BTree
import BTreeCustomDump
import CustomDump
var tree: BTree<String, Int> = BTree()
tree.insert(("apple", 5))
tree.insert(("banana", 3))
tree.insert(("cherry", 8))
customDump(tree)This will output a clean, readable representation:
[
apple: 5,
banana: 3,
cherry: 8
]
Compare this to the standard dump output which is much more verbose:
▿ BTree.BTree<Swift.String, Swift.Int>
▿ root: BTree.BTreeNode<Swift.String, Swift.Int> #0
▿ elements: 3 elements
▿ (2 elements)
- .0: "apple"
- .1: 5
▿ (2 elements)
- .0: "banana"
- .1: 3
▿ (2 elements)
- .0: "cherry"
- .1: 8
- children: 0 elements
- count: 3
- _order: 682
- _depth: 0