Farray is a header-only C++ library that allows for fast initialization of arrays in constant time, using only 1 extra bit of memory. It simplifies array management with no need for dynamic allocations, making it ideal for embedded systems. Experience a significant performance boost while keeping your code clean and efficient.
The Farray project offers a revolutionary approach to initializing and filling C++ arrays efficiently. Leveraging a header-only implementation of the In-Place Initializable Arrays, it allows for constant-time operations including filling, reading, and writing, utilizing only 1 bit of extra memory. This method significantly accelerates array operations, providing substantial performance improvements over standard array handling.
This library is particularly suitable for embedded systems due to its lack of exceptions and dynamic allocations.
Features:
- Constant-time Operations: Achieve
fill(v)
,read(i)
, andwrite(i, v)
operations in O(1) time with minimal memory overhead. - Single-File Solution: Seamlessly integrate a single header file into projects with straightforward inclusion:
#include "farray1.hpp"
- Memory Efficiency: An efficient alternative to traditional arrays, preserving only an extra single bit for operations.
- Circular Indexing: The
A[i]
syntax features circular indexing, whereA[i] is A[i % n]
. This operates seamlessly even for indices that exceed the array limit. - Thorough Tests: The library is rigorously tested to ensure reliability and performance.
Usage:
The Farray1 class can be initialized as follows:
Farray1<int> A(n, 1); // Initializes an array of size n with all elements set to 1.
A[3] = 5; // Set the value of index 3 to 5.
int x = A[12] + A[19] + A[3]; // Reads values.
Performance benchmarking illustrates significant speedups over conventional arrays:
- A speedup of 547 times faster when filling 10% of operations on large arrays.
- Even at minimal fill operations, such as 0.05%, speedups remain impressive at 3 times faster.
For more in-depth insights and advanced features, the Farray project includes a detailed website that covers the algorithm intricacies, advanced functionalities like iterators and templates, and performance analyses.
No comments yet.
Sign in to be the first to comment.