Container Utils

vtr_hash

namespace vtr

Functions

template<class T>
inline void hash_combine(std::size_t &seed, const T &v)

Hashes v and combines it with seed (as in boost)

This is typically used to implement std::hash for composite types.

vtr_memory

namespace vtr
template<class T>
struct aligned_allocator
#include <vtr_memory.h>

aligned_allocator is a STL allocator that allocates memory in an aligned fashion

works if supported by the platform

It is worth noting the C++20 std::allocator does aligned allocations, but C++20 has poor support.

struct t_chunk
#include <vtr_memory.h>

This structure keeps track to chenks of memory

This structure is to keep track of chunks of memory that is being allocated to save overhead when allocating very small memory pieces. For a complete description, please see the comment in chunk_malloc

Functions

template<typename Container>
void release_memory(Container &container)

This function will force the container to be cleared.

It release it’s held memory. For efficiency, STL containers usually don’t release their actual heap-allocated memory until destruction (even if Container::clear() is called).

template<typename T>
T *chunk_new(t_chunk *chunk_info)

Like chunk_malloc, but with proper C++ object initialization.

template<typename T>
void chunk_delete(T *obj, t_chunk*)

Call the destructor of an obj which must have been allocated in the specified chunk.

inline int memalign(void **ptr_out, size_t align, size_t size)
template<typename T>
bool operator==(const aligned_allocator<T>&, const aligned_allocator<T>&)

compare two aligned_allocators.

Since the allocator doesn’t have any internal state, all allocators for a given type are the same.

vtr_pair_util

namespace vtr
template<typename PairIter>
class pair_first_iter
#include <vtr_pair_util.h>

Iterator which derefernces the ‘first’ element of a std::pair iterator.

Public Functions

inline pair_first_iter(PairIter init)

constructor

inline auto operator++()

increment operator (++)

inline auto operator--()

decrement operator (–)

inline auto operator*()

dereference * operator

inline auto operator->()

-> operator

template<typename PairIter>
class pair_second_iter
#include <vtr_pair_util.h>

Iterator which derefernces the ‘second’ element of a std::pair iterator

Public Functions

inline pair_second_iter(PairIter init)

constructor

inline auto operator++()

increment operator (++)

inline auto operator--()

decrement operator ()

inline auto operator*()

dereference * operator

inline auto operator->()

-> operator

vtr_map_util

namespace vtr

Typedefs

using map_key_iter = pair_first_iter<Iter>

An iterator who wraps a std::map iterator to return it’s key.

using map_value_iter = pair_second_iter<Iter>

An iterator who wraps a std::map iterator to return it’s value.

Functions

template<typename T>
auto make_key_range(T b, T e)

Returns a range iterating over a std::map’s keys.

template<typename Container>
auto make_key_range(const Container &c)

Returns a range iterating over a std::map’s keys.

template<typename T>
auto make_value_range(T b, T e)

Returns a range iterating over a std::map’s values.

template<typename Container>
auto make_value_range(const Container &c)

Returns a range iterating over a std::map’s values.