Library

Containers

Generic containers (SC::Vector, SC::SmallVector, SC::Array etc.)

MVP
Dependencies

Memory

SaneCppContainers.h is a library holding some commonly used templated data structures.

While all libraries are designed to let you use your favorite externally provided string / vector classes, there is also an choice of basic containers (mainly Vector<T> incarnations), with support for inline buffer and custom scoped allocators provided by Memory library.

Note: See Tests/InteropSTL/*.cpp for an example of externally provided Container classes.

Dependencies

Dependency Graph

Features

Class Description
SC::Vector SC::Vector
SC::Array SC::Array
SC::SmallVector SC::SmallVector
SC::VectorMap SC::VectorMap
SC::VectorSet SC::VectorSet
SC::ArenaMap SC::ArenaMap

Status

MVP All classes defined in the library should be reasonably stable and safe to use.

Description

Generic data structures are a fundamental building blocks for almost every application.
These are some of commonly used ones for common tasks, and the library will grow adding what's needed.

SC::Vector is the king of all generic containers for this library, being in many case the main backend storage for other containers.

SC::Array mimics all methods of SC::Vector but it's guaranteed never to allocate on heap.
All methods are designed to fail with a [[nodiscard]] return value when the container is full.

SC::SmallVector is the middle ground between SC::Array and SC::Vector.
It's a vector with inline storage for N elements, deriving from SC::Vector and it's designed to be passed everywhere a reference to SC::Vector is needed. This allows the caller to get rid of temporary heap allocations if an estimate of the space required is already known or if it's possible providing a reasonable default.
If this estimation is wrong, heap allocation will happen.

Blog

Some relevant blog posts are:

Vector

Array

SmallVector

VectorMap

VectorSet

ArenaMap

Details

  • SC::Segment is the class representing a variable and contiguous slice of bytes or objects backing both SC::Vector, SC::SmallVector, SC::Array, SC::Buffer and SC::SmallBuffer.
  • Memory layout of a segment is a SC::SegmentHeader holding size and capacity of the segment followed by the actual elements.
  • SC::SegmentHeader is aligned to uint64_t.

Roadmap

Usable Features:

  • Add option to let user disable heap allocations in SC::SmallVector
  • Explicit control on Segment / Vector allocators
  • HashMap<T>
  • Map<K, V>

Complete Features:

  • More specific data structures

💡 Unplanned Features:

  • None

Statistics

Type Lines Of Code Comments Sum
Headers 959 459 1418
Sources 0 0 0
Sum 959 459 1418