id_map

Description

Fast random access id based container.

Access - O(1) Insert - O(1) Erase - O(n) ? Dunno

Vars

std::vector< data < T, Encoding > >

data_

std::deque< id < T > >

free_ids_

Methods

void

reduce_free_ids ( )

id_map ( )

SAW_FORBID_COPY ( id_map )

SAW_DEFAULT_MOVE ( id_map )

error_or < id < T > >

insert ( data < T, Encoding > )

error_or < void >

insert_as ( data < T, Encoding >, id < T > )

error_or < void >

erase ( const id < T > & )

id < T >

next_free_id ( )

error_or < data < T, Encoding > * >

find ( const id < T > & )


Vars Description

std::vector< data < T, Encoding > > data_

Container which stores the primary data

std::deque< id < T > > free_ids_

Container which tracks free’d/fragmented elements within the main container

Methods Description

void reduce_free_ids ( )

Tries to reduce top ids

id_map ( )

Default constructor

SAW_FORBID_COPY ( id_map )


SAW_DEFAULT_MOVE ( id_map )


error_or < id < T > > insert ( data < T, Encoding > )

Inserts an element into the container and returns either an id on success or an error on failure.

error_or < void > insert_as ( data < T, Encoding >, id < T > )

Insert as data with associated id. This can fail when it doesn’t adhere to the standard approach.

error_or < void > erase ( const id < T > & )

Erase a value at this id. If this id isn’t in the map, then it returns an error.

id < T > next_free_id ( )

Tries to return the next free id

error_or < data < T, Encoding > * > find ( const id < T > & )

Tries to find a value based on an id. Returns an error on failure and returns a value pointer on success.