|
|
@ -9,7 +9,7 @@ memvector<T>::memvector( std::string fname ):
|
|
|
|
data_( new mmap_manager( fname ) )
|
|
|
|
data_( new mmap_manager( fname ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !data_->size() ) {
|
|
|
|
if ( !data_->size() ) {
|
|
|
|
data_->resize( byte_io::byte_lenght<unsigned>() );
|
|
|
|
data_->resize( byte_io::byte_length<unsigned>() );
|
|
|
|
byte_io::write<unsigned>( data_->rw_base( 0 ), 0 );
|
|
|
|
byte_io::write<unsigned>( data_->rw_base( 0 ), 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -31,7 +31,7 @@ void memvector<T>::resize( size_type n_s ) {
|
|
|
|
if ( size() >= n_s ) return;
|
|
|
|
if ( size() >= n_s ) return;
|
|
|
|
|
|
|
|
|
|
|
|
using namespace byte_io;
|
|
|
|
using namespace byte_io;
|
|
|
|
data_->resize( n_s * byte_lenght<value_type>() + byte_lenght<unsigned>() );
|
|
|
|
data_->resize( n_s * byte_length<value_type>() + byte_length<unsigned>() );
|
|
|
|
iterator p_end = end();
|
|
|
|
iterator p_end = end();
|
|
|
|
write<unsigned>( data_->rw_base( 0 ), n_s );
|
|
|
|
write<unsigned>( data_->rw_base( 0 ), n_s );
|
|
|
|
while ( p_end != end() ) {
|
|
|
|
while ( p_end != end() ) {
|
|
|
@ -45,10 +45,10 @@ void memvector<T>::insert( const_iterator where, const value_type v ) {
|
|
|
|
assert( !( where < begin() ) );
|
|
|
|
assert( !( where < begin() ) );
|
|
|
|
assert( where <= end() );
|
|
|
|
assert( where <= end() );
|
|
|
|
const unsigned to_idx = where.raw() - data_->ronly_base( 0 );
|
|
|
|
const unsigned to_idx = where.raw() - data_->ronly_base( 0 );
|
|
|
|
data_->resize( ( size() + 1 ) * byte_io::byte_lenght<value_type>() + byte_io::byte_lenght<unsigned>() );
|
|
|
|
data_->resize( ( size() + 1 ) * byte_io::byte_length<value_type>() + byte_io::byte_length<unsigned>() );
|
|
|
|
unsigned char* to = data_->rw_base( to_idx );
|
|
|
|
unsigned char* to = data_->rw_base( to_idx );
|
|
|
|
// make space:
|
|
|
|
// make space:
|
|
|
|
std::memmove( to + byte_io::byte_lenght<value_type>(), to, end().raw() - to );
|
|
|
|
std::memmove( to + byte_io::byte_length<value_type>(), to, end().raw() - to );
|
|
|
|
byte_io::write<value_type>( to, v );
|
|
|
|
byte_io::write<value_type>( to, v );
|
|
|
|
byte_io::write<unsigned>( data_->rw_base( 0 ), size() + 1 );
|
|
|
|
byte_io::write<unsigned>( data_->rw_base( 0 ), size() + 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -68,7 +68,7 @@ void memvector<T>::erase( iterator where ) {
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
void memvector<T>::clear() {
|
|
|
|
void memvector<T>::clear() {
|
|
|
|
data_->resize( byte_io::byte_lenght<uint32_t>() );
|
|
|
|
data_->resize( byte_io::byte_length<uint32_t>() );
|
|
|
|
byte_io::write<uint32_t>( data_->rw_base( 0 ), 0 );
|
|
|
|
byte_io::write<uint32_t>( data_->rw_base( 0 ), 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|