Data structures or containers (e.g. HashMap, RedBlackTree, DoublyLinkedList) are used in almost every program. They offer a particular way of storing and organizing the data, so it can be used efficiently. Problems arise with complex queries on data, which require the functionality of different data structures on the same data. Typically, this is hard to achieve with standard data structure implementations, since each implementation controls its own data storage and organization.
The example bellow demonstrates a simple in-memory database that stores the information about the employees. In order to quickly query the employees by name and have an ordering over the saleries, at least two indexes are required (top image): one index for employees’ name, and another index for employees’ salary. This implementation is not optimal and requires more memory and larger access time. Slib Library compiles a fused data structure (bottom image) that is memory and access extremely efficient.
The generic data structures are implemented as C header files that accept various parameters (preprocessor definitions), which completely specify the implementation of the fused data structure. The user defines these parameters in a separate header file and instantiates the data structure by including the declaration and implementation file of the data structure. After including these files, the user is provided with a set of C structures and functions, which implement the specific fused data structure.
Boost.Intrusive library addresses similar problems.