Skip to content

ext::owned_index_map

An [index_map](Classes/classext_1_1index__map.md) variant that owns its storage and exposes convenience methods to. More...

#include <index_map.h>

Inherits from ext::index_map< BaseIndex, T, std::vector >, std::vector< T >

Public Types

Name
using index_map< BaseIndex, T, Sequence >base_type

Public Functions

Name
voidinit(std::size_t n, const T & value =T())<br>Ensures the container holds exactly n elements, (re)allocating storage if required, and initialises each element to value.
voidinit_no_alloc(const T & value =T())<br>Re-initializes all existing elements to valuewithout altering the container's size or capacity.
voidclear_values()<br>Logical clear: sets every element to T{} (default constructed) while preserving the current allocation.
voidreset_storage()<br>Physical reset: releases all memory and leaves the container empty.

Additional inherited members

Public Functions inherited from ext::index_map< BaseIndex, T, std::vector >

Name
Sequence< T >::referenceoperator[](const std::size_t index)
Sequence< T >::const_referenceoperator[](const std::size_t index) const

Detailed Description

cpp
template <std::size_t BaseIndex,
typename T ,
template< typename... > class Sequence =std::vector>
class ext::owned_index_map;

An [index_map](Classes/classext_1_1index__map.md) variant that owns its storage and exposes convenience methods to.

Template Parameters:

  • BaseIndex The starting (1-based) index expected by the caller.
  • T Stored value type.
  • Sequence Underlying sequential container template (defaults to std::vector). Must satisfy the usual sequence container requirements.
  1. initialize the container with or without triggering a re-allocation, and
  2. clear or fully reset its storage.

These helpers are useful for performance-critical loops (e.g. Monte-Carlo simulations) where frequent zeroing of large containers is required without incurring repeated allocations.

Public Types Documentation

using base_type

cpp
using ext::owned_index_map< BaseIndex, T, Sequence >::base_type =  index_map<BaseIndex, T, Sequence>;

Public Functions Documentation

function init

cpp
inline void init(
    std::size_t n,
    const T & value =T()
)

Ensures the container holds exactly n elements, (re)allocating storage if required, and initialises each element to value.

This is equivalent to Sequence::assign(n, value) but provided here for symmetry with init_no_alloc.

function init_no_alloc

cpp
inline void init_no_alloc(
    const T & value =T()
)

Re-initializes all existing elements to valuewithout altering the container's size or capacity.

The container must already be populated.

An assertion is triggered in debug builds if the container is empty, signalling a potential misuse (e.g. caller expected prior allocation).

function clear_values

cpp
inline void clear_values()

Logical clear: sets every element to T{} (default constructed) while preserving the current allocation.

function reset_storage

cpp
inline void reset_storage()

Physical reset: releases all memory and leaves the container empty.


Updated on 2026-01-09 at 21:59:12 +0000