Code Monkey home page Code Monkey logo

matrixjoeq / c_container Goto Github PK

View Code? Open in Web Editor NEW
19.0 0.0 1.0 436 KB

C container is a STL-like library which implements generic containers in C language. It also implements most of the algorithms in STL algorithm, which can be applied to containers. This library is intended to be helpful for embedded software development, which may still use C language nowadays.

License: MIT License

CMake 1.25% C 67.19% C++ 31.55%
generic-containers stl iterator algorithm c-language

c_container's Introduction

C Container

C container is a STL-like library which implements generic containers in C language. It also implements most of the algorithms in STL algorithm, which can be applied to containers. This library is intended to be helpful for embedded software development, which may still use C language nowadays.

Containers:

  • Sequence containers: list, forward list, vector, deque
  • Associative containers: set, map, multiset, multimap

Container adapters:

  • stack, whose default backend is deque
  • queue, whose default backend is deque
  • priority queue, whose default backend is vector

Notes

  • To implement the most generic containers, elements are all passed by reference, i.e. void* in C language.

  • C deque is implemented very much like C vector, except that it has spare space in both header and tail. By this way, iterator operations are as simple as vector. Algorithms used on deque will be as fast as vector. But it loses the flexibility in memory management. As deque size grows, much larger consecutive memory is required, which may cause memory allocation failure if runs on small memory devices.

  • Like STL containers, each C container has its own iterator type and operation set. Unlike STL iterators, C iterators are implemented by inheritance. All the C iterators have the same base iterator as its first field in the structure, which makes it possible to convert any iterators to base iterator type and pass the iterators to algorithms.

Build from source

In root directory of source code

$ mkdir build
$ cd build
$ cmake ../
$ make

To build unit tests, it requires Google test can be found. Make sure you installed it before building. If cross-compiling for embedded device, change the toolchain used in common.cmake.

License

MIT

c_container's People

Contributors

matrixjoeq avatar navigationquxing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

guitarhua

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.