12#ifndef ARCANE_UTILS_MULTIBUFFER_H
13#define ARCANE_UTILS_MULTIBUFFER_H
17#include "arcane/utils/ArrayView.h"
52 : m_buffer_size(1000), m_current_buffer_size(0), m_nb_in_buffer(0),m_current_buffer(0)
56 : m_buffer_size(
buf_size), m_current_buffer_size(0), m_nb_in_buffer(0),m_current_buffer(0)
61 : m_buffer_size(
ref.m_buffer_size), m_current_buffer_size(0), m_nb_in_buffer(0), m_current_buffer(0)
66 _freeAllocatedBuffers();
75 m_buffer_size =
ref.m_buffer_size;
81 if (!m_current_buffer)
82 _allocateCurrentBuffer();
83 T* v = &(*m_current_buffer)[m_nb_in_buffer];
85 if (m_nb_in_buffer==m_current_buffer_size)
94 if (n>m_current_buffer_size){
96 m_allocated_buffers.add(
bt);
99 if (!m_current_buffer)
100 _allocateCurrentBuffer();
103 if ((m_nb_in_buffer+n)>=m_current_buffer_size)
104 _allocateCurrentBuffer();
105 T* v = &(*m_current_buffer)[m_nb_in_buffer];
107 if (m_nb_in_buffer==m_current_buffer_size)
108 m_current_buffer = 0;
114 m_current_buffer = 0;
115 m_current_buffer_size = 0;
116 _freeAllocatedBuffers();
119 Integer nbAllocatedBuffer() {
return m_allocated_buffers.size(); }
120 Integer bufferSize()
const {
return m_current_buffer_size; }
123 void _freeAllocatedBuffers()
125 for( Integer i=0, s=m_allocated_buffers.size(); i<s; ++i )
126 delete m_allocated_buffers[i];
127 m_allocated_buffers.clear();
136 void _allocateCurrentBuffer()
138 m_current_buffer =
new BufferType(m_buffer_size);
139 m_current_buffer_size = m_buffer_size;
140 m_allocated_buffers.add(m_current_buffer);
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Tampon pour allocation multiple.
MultiBufferT(const MultiBufferT< T > &ref)
Constructeur de recopie.
Integer m_buffer_size
Nombre d'élément d'un tampon.
Integer m_nb_in_buffer
Nombre d'éléments dans le tampon actuel.
BufferType * m_current_buffer
Tampon actuel.
T * allocOne()
Alloue un nouvel élément.
Integer m_current_buffer_size
Nombre d'éléments max du tampon courant.
ArrayView< T > allocMany(Integer n)
Alloue n éléments.
UniqueArray< BufferType * > m_allocated_buffers
Liste de tous les tampons.
void operator=(const MultiBufferT< T > &ref)
Opérateur de recopie (interdit)
Int32 Integer
Type représentant un entier.