Skip to content

feat: extend Treemap for any type T which implements Lesser or cmp.Ordered #138

Merged
wenchy merged 4 commits intomasterfrom
treemap-new2
Nov 11, 2025
Merged

feat: extend Treemap for any type T which implements Lesser or cmp.Ordered #138
wenchy merged 4 commits intomasterfrom
treemap-new2

Conversation

@Kybxd
Copy link
Copy Markdown
Collaborator

@Kybxd Kybxd commented Nov 8, 2025

This is the infrastructure of multi-key ordered index.

@wenchy
Copy link
Copy Markdown
Member

wenchy commented Nov 10, 2025

Another solution to be discussed:

  1. Do not change the treemap.
  2. Just use hierarchical treemap just like hierarchical hashmap in protoconf.

Comment thread pkg/treemap/redblacktree/iterator.go Outdated

// Iterator holding the iterator's state
type Iterator[K constraints.Ordered, V any] struct {
type Iterator[K, V any] struct {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the PR title suggests "for any type T which implements Less(T) bool", So the K should be type just like https://pkg.go.dev/sort#Interface.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K is defined as any type for compatibility with basic types like int64 or string.

Comment thread pkg/treemap/redblacktree/redblacktree.go Outdated
Comment thread go.mod
Comment thread pkg/treemap/redblacktree/redblacktree.go
Comment thread pkg/treemap/redblacktree/serialization.go
Comment thread pkg/treemap/treemap_test.go
Comment thread pkg/treemap/redblacktree/iterator.go
Comment thread pkg/treemap/redblacktree/iterator.go
Comment thread pkg/treemap/redblacktree/redblacktree.go
@wenchy wenchy changed the title feat: support New2 of Treemap for any type T which implements Less(T) bool feat: extend Treemap for any type T which implements Lesser or cmp.Ordered Nov 11, 2025
@wenchy wenchy merged commit d6d0e1a into master Nov 11, 2025
@wenchy wenchy deleted the treemap-new2 branch November 11, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants