Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
linhpn99 committed Aug 15, 2024
1 parent 4c8b367 commit 7d1e8c2
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions examples/gno.land/p/demo/avl/indexed_tree.gno
Original file line number Diff line number Diff line change
Expand Up @@ -206,28 +206,15 @@ func (tree *IndexedTree) ReverseIterateByOffset(offset int, count int, cb IterCb
return tree.mainTree.ReverseIterateByOffset(offset, count, cb)
}

// getIndexStats provides statistics about indexes
func (tree *IndexedTree) getIndexStats() map[string]int {
stats := make(map[string]int)
for field, index := range tree.indexes {
stats[field] = index.Size()
}
return stats
}

// Render provides a string representation of the overall status of the IndexedTree
func (tree *IndexedTree) Render() string {
// Get statistics for indexes
indexStats := tree.getIndexStats()

// Initialize the result string with the main tree status
result := "IndexedTree Status:\n"
result += "Main Tree Size: " + ufmt.Sprintf("%d", tree.Size()) + "\n"
result += "Index Count: " + ufmt.Sprintf("%d", tree.IndexCount()) + "\n"

// Append statistics for each index
result += "Indexes:\n"
for field, count := range indexStats {
for field, index := range tree.indexes {
count := index.Size()
result += " Field: " + field + ", Count: " + ufmt.Sprintf("%d", count) + "\n"
}

Expand Down

0 comments on commit 7d1e8c2

Please sign in to comment.