diff options
author | Valery Piashchynski <[email protected]> | 2021-06-05 21:51:50 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-05 21:51:50 +0300 |
commit | 459e29a85fe5c8571920a602ceb8374bbb893f49 (patch) | |
tree | 83f9c35ff54945bd8173d0e7201234d17341007c /pkg/bst/bst.go | |
parent | 0323e070103cc2c30d2cdfb12719d753acafe151 (diff) | |
parent | 7995c44d47075cca01c44120e5617d1d90b2a039 (diff) |
#705 feat(websockets): bug fixing and polishing
#705 feat(websockets): bug fixing and polishing
Diffstat (limited to 'pkg/bst/bst.go')
-rw-r--r-- | pkg/bst/bst.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/bst/bst.go b/pkg/bst/bst.go index 664937ba..f8426b12 100644 --- a/pkg/bst/bst.go +++ b/pkg/bst/bst.go @@ -52,6 +52,22 @@ func (b *BST) Insert(uuid string, topic string) { } } +func (b *BST) Contains(topic string) bool { + curr := b + for curr != nil { + switch { + case topic < curr.topic: + curr = curr.left + case topic > curr.topic: + curr = curr.right + case topic == curr.topic: + return true + } + } + + return false +} + func (b *BST) Get(topic string) map[string]struct{} { curr := b for curr != nil { |