Comments (5)
I added a PATH_HINT markdown file.
from btree.
I wonder if this API would be helpful:
type PathContext struct {
bt *BTree
hint PathHint
}
func (c *PathContext) Delete(key interface{}) interface{} {
return c.bt.DeleteHint(key, &c.hint)
}
func (c *PathContext) Get(key interface{}) interface{} {
return c.bt.GetHint(key, &c.hint)
}
func (c *PathContext) Set(key interface{}) interface{} {
return c.bt.SetHint(key, &c.hint)
}
func main() {
bt := New(func(a, b interface{}) bool {
return a.(string) < b.(string)
})
c := bt.PathContext()
c.Set("abc")
fmt.Println(c.Get("abc"))
c.Delete("abc")
}
https://play.golang.org/p/wWcBVE-YwfY
from btree.
Ok. I'll try to put together some documentation on the README.
from btree.
The benchmark code helped me understand the API, it wasn't clear to me prior to reading that that the functions using path hints mutated the hint
from btree.
@tommie Your PathContext idea is slick. I'm not sure that it's best suited for adding directly to this library but I can see how it others might find it convenient.
from btree.
Related Issues (20)
- Generics HOT 8
- ADMIN
- The Map[K, V].find() API design discussion HOT 4
- With go1.18rc1 getting error: constraints: package constraints is not in GOROOT HOT 10
- Seek does not initialize iter item HOT 4
- MapIter[K,V] Seek method does not initialize the item HOT 2
- Documentation for Get() is inaccurate
- Use of interface{} and constant type/length keys
- Breaking changes in switching from uint64 to atomic.Uint64 HOT 1
- Does btree.Map use concurrency locks? HOT 2
- Investigate if we can re-use allocated memory after `Map.Clear()` HOT 1
- How does copy-on-write actually work?
- Map for pre-generics version of Go
- possible panic when writing from multiple goroutines HOT 1
- is b+ tree surport? HOT 5
- add put method to set kvpairs , if old value exists, return val
- Do we need a rebalancing process for the btree? HOT 2
- question about crash during iteration (probably because of mutation during iteration) HOT 2
- Delete during Ascend in thread-safe tree HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btree.