Geogram  Version 1.9.1
A programming library of geometric algorithms
GEOGen::PointAllocator Class Reference

An allocator for points that are created from intersections in GenericVoronoiDiagram. More...

#include <geogram/voronoi/generic_RVD_vertex.h>

Public Member Functions

 PointAllocator (coord_index_t dim)
 Creates a new empty PointAllocator. More...
 
double * new_item ()
 Allocates a new point. More...
 
void clear ()
 Clears this PointAllocator.
 
 ~PointAllocator ()
 PointAllocator destructor. More...
 
coord_index_t dimension () const
 Gets the dimension of the points stored in this PointAllocator.
 

Protected Types

enum  { CHUNK_SHIFT = 8 , CHUNK_SIZE = 1 << CHUNK_SHIFT , CHUNK_MASK = CHUNK_SIZE - 1 }
 Constants that determine the size of a chunk.
 

Protected Member Functions

void grow ()
 Allocates a new chunk of memory.
 
double * item (index_t i)
 Gets a pointer to one of the allocated points from its index. More...
 

Detailed Description

An allocator for points that are created from intersections in GenericVoronoiDiagram.

Implementation is an array of chunk. We do not use std::deque since we want to control the chunk size, and we want to clear it without deallocating memory to avoid many calls to memory allocator (which would probably slow down the Windows version a lot, there seems to be a global multithreading lock on malloc()).

In most cases, only the first chunk is used (but some degenerate cases may use more). There seems to be no measurable overhead as compared to a contiguous array in our scenario.

Note
This is an internal implementation class, not meant to be used by client code.

Definition at line 668 of file generic_RVD_vertex.h.

Constructor & Destructor Documentation

◆ PointAllocator()

GEOGen::PointAllocator::PointAllocator ( coord_index_t  dim)
inline

Creates a new empty PointAllocator.

Parameters
[in]dimdimension of the points to be allocated

Definition at line 674 of file generic_RVD_vertex.h.

◆ ~PointAllocator()

GEOGen::PointAllocator::~PointAllocator ( )
inline

PointAllocator destructor.

This releases all allocated chunks.

Definition at line 704 of file generic_RVD_vertex.h.

Member Function Documentation

◆ item()

double* GEOGen::PointAllocator::item ( index_t  i)
inlineprotected

Gets a pointer to one of the allocated points from its index.

Parameters
[in]ithe index of the point in this PointAllocator
Returns
A pointer to the coordinates of the point

Definition at line 747 of file generic_RVD_vertex.h.

◆ new_item()

double* GEOGen::PointAllocator::new_item ( )
inline

Allocates a new point.

Returns
a pointer to the coordinates of the new point. Memory ownership remains to this PointAllocator.

Definition at line 685 of file generic_RVD_vertex.h.


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