Comments (4)
The return value of find
is not the inverse of the input to GetAt
. The find
method does not return the index of a key in the entire Map
, it only returns the index of a key in the a single mapNode
.
Rather, we would need to create a new inverse function to GetAt
, such as:
func (tr *Map[K, V]) IndexOf(key K) (int, bool)
Which is certainly a possibility.
from btree.
Oh, I see, I've made a mistake.
Actually, I want to do a range search; e.g. :
func (m *Map[K, V]) RangeDo(keyLow, keyHigh K, fn func(key K, value Value)) {...}
then, used like this:
m := NewMap[int, string](...)
// ... some init actions
m.RangeDo(10, 100, func(key K, value Value) {... })
so, I think, I need Find(key K) (int, bool)
from btree.
For an inclusive range operation you can use the Ascend
function.
min, max := 10, 100
m.Ascend(min, func(key int, value string) bool {
if key > max {
return false
}
// TODO: something with the key/value pair
return true
})
from btree.
For an inclusive range operation you can use the
Ascend
function.min, max := 10, 100 m.Ascend(min, func(key int, value string) bool { if key > max { return false } // TODO: something with the key/value pair return true })
For an inclusive range operation you can use the
Ascend
function.min, max := 10, 100 m.Ascend(min, func(key int, value string) bool { if key > max { return false } // TODO: something with the key/value pair return true })
Does this mean we are doing a full scan on the dataset? A range query on a btree would be best to leverage the btree structure and achieve a O(log n) complexity.
from btree.
Related Issues (20)
- Generics HOT 8
- ADMIN
- 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
- PathHint on Map/Set?
- 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.