项目作者: kostakis

项目描述 :
A generic queue data structure implementation in c.
高级语言: C
项目地址: git://github.com/kostakis/Generic-Queue.git
创建时间: 2019-02-12T00:22:45Z
项目社区:https://github.com/kostakis/Generic-Queue

开源协议:

下载


Generic queue

A simple C implementation of a generic queue data structure.
Provides all the basics methods of a queue.
It can be used as a static library

Supported Operations

  • enqueue
  • dequeue
  • front
  • reverse
  • getSize
  • clearQueue

Basic Usage

  1. include "queue.h"
  2. /*.........*/
  3. typedef struct Foo {
  4. int a;
  5. }Foo;
  6. Foo f;
  7. f.a =100;
  8. queue* q = createQueue(sizeof(Foo));
  9. enqueue(q, &f);
  10. Foo temp;
  11. dequeue(q, &temp);
  12. destroyQueue(&q);
  13. /*..........*/

See main.c for a complete example.

Bulding

Linux

Run Example

  1. cmake -S . -B build/
  2. cd build;
  3. make example
  4. ./example

You can also run make genericQueue to build just the library

Unit Tests

Also have created some basic unit tests using gtest and C++.
Test are compiled automatically but you must run them.

  1. cmake -S . -B build/
  2. cd build;
  3. make all # This also compiles and executes the unit tests
  4. ctest

Windows

  1. cmake -S . -B build/
  2. cd build;
  3. cmake --build .
  4. ctest # To run the tests

In the Debug/ folder the example is located together with the static library.

You can also open the solution file with visual studio.