Skip to content

Latest commit

ย 

History

History
126 lines (90 loc) ยท 3.2 KB

README.en.md

File metadata and controls

126 lines (90 loc) ยท 3.2 KB

DStruct

DStruct is a portable and structurally simple data structure template library.

Features - Usage - Core - Who is using - Other - ไธญๆ–‡
Design Philosophy - Interface Documentation - Static Memory Allocator (SMA) - Porting Guide - Related Videos

Features

  • Easily portable, no dependent std-lib
  • Easy to use, like std-lib style
  • Easy to learn, customize, and improve
  • Provides custom allocators interface
  • Supports bare-metal/small-memory devices
  • Provides simple static memory management/allocator - SMA
  • Modern C++/generic structures

Usage

1. Source Code and Configuration

  • Download the source code to your local machine.
  • Add the root directory of the DStruct library to your include path.
  • Customize allocator & implement the dstruct-port.h interface - optional

2. Code Example - Dynamic Memory

#include <iostream>
#include <dstruct.hpp>

int main() {
    dstruct::Array<int, 10> arr(2);

    decltype(arr)::ValueType val = 6;
    arr[0] = arr[-1] = val;

    for (int i = 0; i < arr.size(); i++) {
        std::cout << arr[-(i + 1)] << " : " << arr[i] << std::endl;
    }

    return 0;
}

3. Code Example - Static Memory

Use static memory SMA, support no memory management environment (such as: bare metal)

#include <dstruct.hpp>

int main() {
    //dstruct::Vector<int> dVec;
    dstruct::smemory::Vector<int> sVec;

    for (int i = 0; i < 10; i++) {
        sVec.push_back(i);
    }

    for (auto v : sVec)
        DSTRUCT_ASSERT(v == i++);

    while (!sVec.empty()) {
        sVec.pop_back();
    }

    return 0;
}

Note: Static data structures are defined in the dstruct::smemory space, and interfaces and usage are the same as the data structures supported by dynamic memory

Core

.
โ”œโ”€โ”€ algorithm.hpp
โ”œโ”€โ”€ common.hpp
โ”œโ”€โ”€ ds
โ”‚   โ”œโ”€โ”€ array
โ”‚   โ”‚   โ”œโ”€โ”€ Array.hpp
โ”‚   โ”‚   โ””โ”€โ”€ Vector.hpp
โ”‚   โ”œโ”€โ”€ Heap.hpp
โ”‚   โ”œโ”€โ”€ linked-list
โ”‚   โ”‚   โ”œโ”€โ”€ DoublyLinkedList.hpp
โ”‚   โ”‚   โ”œโ”€โ”€ EmbeddedList.hpp
โ”‚   โ”‚   โ”œโ”€โ”€ LinkedList.hpp
โ”‚   โ”‚   โ””โ”€โ”€ SinglyLinkedList.hpp
โ”‚   โ”œโ”€โ”€ queue
โ”‚   โ”‚   โ”œโ”€โ”€ DoubleEndedQueue.hpp
โ”‚   โ”‚   โ””โ”€โ”€ Queue.hpp
โ”‚   โ”œโ”€โ”€ stack
โ”‚   โ”‚   โ”œโ”€โ”€ Stack.hpp
โ”‚   โ”‚   โ””โ”€โ”€ XValueStack.hpp
โ”‚   โ””โ”€โ”€ tree
โ”‚       โ”œโ”€โ”€ BinarySearchTree.hpp
โ”‚       โ”œโ”€โ”€ BinaryTree.hpp
โ”‚       โ”œโ”€โ”€ EmbeddedBinaryTree.hpp
โ”‚       โ””โ”€โ”€ tree-base.hpp
โ”œโ”€โ”€ Iterator.hpp
โ”œโ”€โ”€ StaticMemAllocator.hpp
โ””โ”€โ”€ types.hpp

Who-is-using

Other