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

a sparse array suitable for large sizes 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 ()
 

Public Attributes

const uint64_t page_addr_mask = (1 << PAGE_ADDR_BITS) - 1
 
const uint64_t page_size = (1 << PAGE_ADDR_BITS)
 
const unsigned page_count = (SIZE + page_size - 1) / page_size
 
const 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

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 36 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 52 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 56 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 91 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 79 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 66 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 101 of file sparse_array.h.


The documentation for this class was generated from the following file: