Blender  V3.3
Classes | Namespaces | Macros | Typedefs
BLI_vector.hh File Reference
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <memory>
#include "BLI_allocator.hh"
#include "BLI_index_range.hh"
#include "BLI_listbase_wrapper.hh"
#include "BLI_math_base.h"
#include "BLI_memory_utils.hh"
#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

Classes

class  blender::Vector< T, InlineBufferCapacity, Allocator >
 

Namespaces

 blender
 

Macros

#define UPDATE_VECTOR_SIZE(ptr)    (ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_)
 

Typedefs

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T))>
using blender::RawVector = Vector< T, InlineBufferCapacity, RawAllocator >
 

Detailed Description

A blender::Vector<T> is a dynamically growing contiguous array for values of type T. It is designed to be a more convenient and efficient replacement for std::vector. Note that the term "vector" has nothing to do with a vector from computer graphics here.

A vector supports efficient insertion and removal at the end (O(1) amortized). Removal in other places takes O(n) time, because all elements afterwards have to be moved. If the order of elements is not important, remove_and_reorder can be used instead of remove for better performance.

The improved efficiency is mainly achieved by supporting small buffer optimization. As long as the number of elements in the vector does not become larger than InlineBufferCapacity, no memory allocation is done. As a consequence, iterators are invalidated when a blender::Vector is moved (iterators of std::vector remain valid when the vector is moved).

blender::Vector should be your default choice for a vector data structure in Blender.

Definition in file BLI_vector.hh.

Macro Definition Documentation

◆ UPDATE_VECTOR_SIZE

#define UPDATE_VECTOR_SIZE (   ptr)     (ptr)->debug_size_ = static_cast<int64_t>((ptr)->end_ - (ptr)->begin_)

Definition at line 99 of file BLI_vector.hh.