Giter Site home page Giter Site logo

stackvector's Introduction

Stack Allocated Vector

Visit the wiki for more information

Description

This is a header only library, so you can just download the header file and include it in your project (with the LICENSE naturally). A very similar and easy replacement where required of std::vector<class T> data structure, the key difference being the data is dynicamically allocated on the stack, resulting in being cache-coherent.

Normally, for general use-cases dynamic stack allocation should be avoided as it may result code being unsafe and/or unstable due to the nature of dynamic stack allocation and other methods should be sought after.

However, some circumstances may call for dynamic stack allocation and can be seen in areas where speed of execution is important such as real-time 3D renderers, raytracres, patch tracers or game engines, as some parts in memory may be read and written to multiple times and if it were allocated on the heap the time taken would be a lot longer comparitively to stack allocated memory.

I wouldn't say this is the best solution out there, but this is my approach to it. The implementation is similar to that of the std::vector implementation, so it should be a general drop-in replace.

Usage

  1. If you want to use this library in your code then just include the stack_vector.hpp file located at ~/StackVector/include/
  2. To run tests go to the Project Setup section.

Project Setup

$${\color{yellow}You \space may \space use \space CMake \space or \space Premake \space to \space generate \space your \space project. }$$

CMake

If you want to run the tests for yourself, download CMake to your respective platform and then generate necessary project files. You may use the CMake GUI if you find it easier over using the CLI. Just do configure then generate

Otherwise use the CLI at the project working directory like so:

Configure

Windows

cd build; cmake -G "Visual Studio 17 2022" ..; cd ..

Linux

cd build; cmake -G "Unix Makefiles" ..; cd ..

Build

Debug

cmake --build . --config Debug

Release

cmake --build . --config Release

Premake

If you want to run the tests for yourself, download Premake5 to your respective platform and then generate necessary project files. This is platform dependent so here is a quick guide:

Windows

./premake5 vs2022

Linux

./premake5 gmake2

MacOS

I don't own a Mac and have never programmed on Mac, so fend for yourselves.

More information can be found here.

stackvector's People

Contributors

kamilkrauze avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.