go-datastructures | A collection of useful , performant , and threadsafe Go | Map library
kandi X-RAY | go-datastructures Summary
kandi X-RAY | go-datastructures Summary
Go-datastructures is a collection of useful, performant, and threadsafe Go datastructures.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of go-datastructures
go-datastructures Key Features
go-datastructures Examples and Code Snippets
Community Discussions
Trending Discussions on go-datastructures
QUESTION
I'm currently playing with some ideas wrt CRF-ish work and I have an idea that I need help with.
Minimal ProblemI've got a bunch of function objects (think something expensive like neural nets). They are applied onto a linear buffer (think an array of float
s or byte
s) but at varying intervals. So they look like that (think of Start and End as "apply Object to buf[Start:End]
":
ANSWER
Answered 2017-Oct-22 at 16:26This solution isn't particularly memory-efficient, but if I understand you correctly, it should allow for a relatively simple implementation of the functionality you want.
Keep an array or slice
funcs
of all your function objects, so that they each have a canonical integer index, and can be looked up by that index.Keep a slice of ints
s
that is always the same size as your buffer of floats; it maps a particular index in your buffer to a "function index" in the slice of functions. You can use -1 to represent a number that is not part of any interval.Keep a slice of (int, int) pairs
intervals
such thatintervals[i]
contains the start-end indices for the function stored atfuncs[i]
.
I believe this enables you to implement your desired functionality without too much hassle. For example, to query by index i
, look up s[i]
, then return funcs[s[i]]
and intervals[s[i]]
. When changes occur to the buffer, change s
as well, cross-referencing between s
and the intervals
slice to figure out if neighboring intervals are affected. I'm happy to explain this part in more detail, but I don't totally understand the requirements for interval updates. (When you do an interval insert, does it correspond to an insert in the underlying buffer? Or are you just changing which buffer elements are associated with which functions? In which case, does an insert cause a deletion at the beginning of the next interval? Most schemes should work, but it changes the procedure.)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-datastructures
Install Go 1.3 or higher.
Run go get github.com/Workiva/go-datastructures/...
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page