scc 2025.09
SystemC components library
util::sparse_array< T, SIZE, PAGE_ADDR_BITS > Class Template Reference

a sparse array suitable for large sizes with compile time constants for performance More...

#include <sparse_array.h>

Public Types

using page_type = std::array<T, 1 << PAGE_ADDR_BITS>

Public Member Functions

 sparse_array ()
 ~sparse_array ()
T & operator[] (uint32_t addr)
page_type & operator() (uint32_t page_nr)
bool is_allocated (uint32_t addr)
uint64_t size ()

Static Public Attributes

static constexpr uint64_t page_addr_mask = (1 << PAGE_ADDR_BITS) - 1
static constexpr uint64_t page_size = (1 << PAGE_ADDR_BITS)
static constexpr unsigned page_count = (SIZE + page_size - 1) / page_size
static constexpr uint64_t page_addr_width = PAGE_ADDR_BITS

Protected Attributes

std::array< page_type *, SIZE/(1<< PAGE_ADDR_BITS)+1 > arr

Detailed Description

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
class util::sparse_array< T, SIZE, PAGE_ADDR_BITS >

a sparse array suitable for large sizes with compile time constants for performance

a simple array which allocates memory in configurable chunks (size of 2^PAGE_ADDR_BITS), used for large sparse arrays. Memory is allocated on demand

Definition at line 123 of file sparse_array.h.

Member Typedef Documentation

◆ page_type

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
using util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::page_type = std::array<T, 1 << PAGE_ADDR_BITS>

Definition at line 135 of file sparse_array.h.

Constructor & Destructor Documentation

◆ sparse_array()

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::sparse_array ( )
inline

the default constructor

Definition at line 139 of file sparse_array.h.

◆ ~sparse_array()

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::~sparse_array ( )
inline

the destructor

Definition at line 143 of file sparse_array.h.

Member Function Documentation

◆ is_allocated()

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
bool util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::is_allocated ( uint32_t addr)
inline

check if page for address is allocated

Parameters
addrthe address to check
Returns
true if the page is allocated

Definition at line 178 of file sparse_array.h.

◆ operator()()

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
page_type & util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::operator() ( uint32_t page_nr)
inline

page fetch operator

Parameters
page_nrthe page number ot fetch
Returns
reference to page

Definition at line 166 of file sparse_array.h.

◆ operator[]()

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
T & util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::operator[] ( uint32_t addr)
inline

element access operator

Parameters
addraddress to access
Returns
the data type reference

Definition at line 153 of file sparse_array.h.

◆ size()

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
uint64_t util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::size ( )
inline

get the size of the array

Returns
the size

Definition at line 188 of file sparse_array.h.

Member Data Documentation

◆ arr

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
std::array<page_type*, SIZE / (1 << PAGE_ADDR_BITS) + 1> util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::arr
protected

Definition at line 191 of file sparse_array.h.

◆ page_addr_mask

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
uint64_t util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::page_addr_mask = (1 << PAGE_ADDR_BITS) - 1
staticconstexpr

Definition at line 127 of file sparse_array.h.

◆ page_addr_width

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
uint64_t util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::page_addr_width = PAGE_ADDR_BITS
staticconstexpr

Definition at line 133 of file sparse_array.h.

◆ page_count

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
unsigned util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::page_count = (SIZE + page_size - 1) / page_size
staticconstexpr

Definition at line 131 of file sparse_array.h.

◆ page_size

template<typename T, uint64_t SIZE, unsigned PAGE_ADDR_BITS = 24>
uint64_t util::sparse_array< T, SIZE, PAGE_ADDR_BITS >::page_size = (1 << PAGE_ADDR_BITS)
staticconstexpr

Definition at line 129 of file sparse_array.h.


The documentation for this class was generated from the following file:
  • /home/eyck/Projects/MINRES/SystemC-Components/src/common/util/sparse_array.h