breese / trial.circular Goto Github PK
View Code? Open in Web Editor NEWCircular span
License: Boost Software License 1.0
Circular span
License: Boost Software License 1.0
Hi,
thanks for this nice project! It was really easy to integrate and use and was the only circular buffer API that fulfilled my needs of being able to bulk resize.
Regarding bulk insertion and removal operations, I was wondering if there would be an option to offer some kind of higher-level API. You offer the segment views, but it is a bit clunky to put in user code and requires some knowledge of the internals of the buffer. I haven't found a better way, but of course it might also be that I just missed it.
For example, to insert a block of data, I currently use:
// add `std::span<std::byte> data` to the end of `circular::span<std::byte> q`
auto copyDestFirstSeg{q.first_unused_segment()};
auto copyDestLastSeg{q.last_unused_segment()};
q.expand_back(data.size());
const auto bytesInFirstSeg{std::min(data.size(), copyDestFirstSeg.size())};
const auto bytesInLastSeg{data.size() - bytesInFirstSeg};
std::copy_n(data.begin(), bytesInFirstSeg, copyDestFirstSeg.begin());
if (bytesInLastSeg > 0) {
std::copy_n(data.begin() + bytesInFirstSeg, bytesInLastSeg, copyDestLastSeg.begin());
}
Could operations like this be added to the buffer or maybe as a free-standing function? I can imagine it is quite common to want to do this with a circular buffer and I guess it is also the reason you provide the segment queries in the first place.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.