No activity tracked
tomhea / farray Goto Github PK
View Code? Open in Web Editor NEWInitialize / Fill C++ array fast - O(1) time with only 1 extra bit of memory.
License: BSD 2-Clause "Simplified" License
Initialize / Fill C++ array fast - O(1) time with only 1 extra bit of memory.
License: BSD 2-Clause "Simplified" License
Many core systems nowadays expect single-header libs or generally low-level libs to not be dependent on C++ exceptions.
So to make this lib more appealing I propose to make it exception-less by default (or at least optionally exception-less).
Traveling through 0->b-1 blocks, and if chained - take the chained block, else the current block.
Also iterate over the last values, above all blocks.
Fix internal links, and also set old links [linking to the Github wiki] from outside, to the new Github-pages.
Add an example
folder with example code using the direct-functions, and the Farray1, Farray, and NFarray classes.
operator[] using a "proxy" object.
First of all - Farray stands for Fillable array.
As I see it - the final project should have 3 main classes, and one namespace:
file farray1.hpp:
namespace Farray1Direct
- should hold the 1bit implementation of fill, read, write, writtenSize, begin/end (with an interior namespace for the interior functions).class Farray1
- The wrapper for the 1bit functions ([], =, iterator, no need for A,n,flag each time).file farray.hpp:
class Farray
- The implementation of the log(n) bits (b and def outside), with all ([], =, iterator, ...).file nfarray.hpp:
class NFarray : public Farray
- extends Farray with numerical features. ++,--,+=,-=,*=,/= (for proxy, and for whole Array), and maintaining the sum of all vars. All ops should still be O(1).All classes shouldn't be under any namespace.
It should all start by closing the current project as farray1.hpp. The iterator's begin/end should be implemented in the namespace area, while the Holder/Farray1 class should only contain wrapper begin/end to the direct ones.
Then iterators should be automatically tested (not printable tests), for the direct and wrapping iterators both.
Then the file's, class', and namespace's names should be changed, the project's README should be updated, and the project's name should be set to Farray.
Also - the tests.cpp should just call tests_farray1.cpp, which will hold all the logic.
Only then, the Farray should be born.
The Farray would hold more bytes in memory but will be faster, as each write will init a smaller block (for int:32 vs size_t:64 - 2.5 smaller).
The farray.hpp and tests_farray.cpp should be mainly based on farray1.hpp and tests_farray1.cpp.
The farray.hpp should be simplified as much as it can, and also contain options for other sizes (not just size_t) in a templated fashion.
Then after many testing (tests.cpp should also call tests_farray.cpp of course), and README update:
The NFarray should come to life (stands for Numerical Fillable array).
It should have a ++,--,+=,-=,*=,/= for the proxy, and also ++,--,+=,-=,*=,/= for the NFarray instance (update all at once). The += for example is meant for adding a T variable to the proxy (or to all of the array's elements).
Also, It will feature a sum() O(1) operation to retrieve the sum of the whole array (by maintaining a sum var).
Doing that for the whole array is by saving x,y for each NFarray instance, s.t. new_read(A, i) returns x*read(A,i)+y, while new_write(A, i, v) does write(A, i, (v-y)/x).
I'll just remind future someone to execute fill(0) instead of *=0, because otherwise it will cause some problems with writing new values (div by 0).
And just remember - user caused overflow is not our concern, so no need to check for those.
Then NFarray should be tested (in tests_nfarray.cpp also called from tests.cpp), and the README should be updated.
Then, and Only Then, The Farray project should be complete.
Add the new features - operator[] read/write, operator= fill, written-indices iterator, to README.
The old read/write should only be seen in the direct function mode.
The readme should be use a simple and main example.
This could allow some interesting use cases which need something like null-or-value
semantics before first write.
Start creating the Farray GitHub-pages site locally, and use the following plugins:
And find a solution for a normal sidebar and simple navigation in the website.
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.