Skip to content
Very lightweight, versatile and speedy C containers library. Source code of library is portable, conforms to ANSI C 89/90 Standard.
C C++
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Android
FreeBSD
Linux
Win32
Win64
macOS
HISTORY.txt
MdzAscii.h
MdzVector.h
README.md
_config.yml
google9ff4cdc65405e44f.html
mdz_ascii.h
mdz_assert.h
mdz_containers.h
mdz_types.h
mdz_utf16.h
mdz_utf8.h
mdz_vector.h
mdz_wchar.h

README.md

In course of WorldTennisTracker software development a lot of reusable and portable source code has appeared. In this github account of maxdz Software GmbH we would like to publish libraries encapsulating this code for external use.

Table of Contents

mdz_containers Overview
mdz_vector Overview
mdz_ascii Overview
mdz_wchar Overview
mdz_utf8 Overview
mdz_utf16 Overview
Licensing info
Credits

mdz_containers Overview

mdz_containers - is a very lightweight, versatile and speedy C containers library. Source code of library is portable, conforms to ANSI C 89/90 Standard.

Linux libraries are built against Linux Kernel 2.6.18 - and thus should be compatible with Debian (from ver. 4.0), Ubuntu (from ver. 8.04), Fedora (from ver. 9)

FreeBSD libraries - from FreeBSD ver. 7.0

Win32 libraries are built using Visual Studio Platform Toolset "v90", thus are compatible with Windows versions from Windows 2000.
Win64 libraries are built using Visual Studio Platform Toolset "v100", thus are compatible with Windows versions from Windows XP.
Some CRT functions are inlined in Visual C++ 2015. Therefore if you are using Platform Toolset "v140" or later with mdz_containers Static Library - please link also with "legacy_stdio_definitions.lib". It will resolve such functions.

Android x86/armeabi-v7a - from Android API level 16 ("Jelly Bean" ver. 4.1.x)
Android x86_64/arm64-v8a - from Android API level 21 ("Lollipop" ver. 5.0)

macOS - x86_64, from MacOS X v10.6.0

mdz_vector Overview

Wiki: mdz_vector Wiki
file: "mdz_vector.h"

Our vector implementation is on par or faster than corresponding Glib functions and significantly faster than STL implementations, especially on larger sizes.
(results of performance-comparisons on Windows, FreeBSD and Linux will be attached here soon)

vector is implemented in defensive programming manner with strict input parameters checking. It means mdz_false or some other error indication will be returned if one or several input parameters are invalid - even if such an invalidity doesn't lead to inconsistence (for example adding or removing 0 items).

Several usage-scenarios are possible:

  • low-level - raw C interface, using mdz_vector.h header files
  • higher-level - using CMdzVector C++ "wrapper" around mdz_vector.h functions

Please take a look at "mdz_vector.h" file or mdz_vector Wiki site for detailed functions descriptions.

Code Example (low-level use)

mdz_containers_init() with license information should be called for library initialization before any subsequent calls. Following call should be used for test-license:

#include <mdz_containers.h>

int main(int argc, char* argv[])
{
  mdz_bool bRet = mdz_containers_init("test-name", "test-surname", "test-email", "38e82738ff04abc00e939d69591815e1");
  ...
}

NOTE: Capacity of data structures is limited to 1200 elements for test-license.

After library initialization call mdz_vector_create() for vector creation. There should be also symmetric mdz_vector_destroy() call for every init, otherwise allocated for vector memory remains occupied:

#include <mdz_containers.h>
#include <mdz_vector.h>

int main(int argc, char* argv[])
{
  mdz_bool bRet = mdz_containers_init("test-name", "test-surname", "test-email", "38e82738ff04abc00e939d69591815e1");
  
  // initialize pStringVector and pIntVector
  
  mdz_Vector* pStringVector = mdz_vector_create(sizeof(char*)); // create vector of char* elements.
  mdz_Vector* pIntVector = mdz_vector_create(sizeof(int)); // create vector of int elements.
  ...
  ...
  // use pStringVector and pIntVector
  ...
  ...
  // destroy pStringVector and pIntVector
  
  mdz_vector_destroy(&pStringVector); // after this pStringVector should be NULL
  mdz_vector_destroy(&pIntVector); // after this pIntVector should be NULL
  
  ...
}

Use mdz_Vector* pointer for subsequent library calls:

#include <mdz_containers.h>
#include <mdz_vector.h>

int main(int argc, char* argv[])
{
  mdz_bool bRet = mdz_containers_init("test-name", "test-surname", "test-email", "38e82738ff04abc00e939d69591815e1");
  
  mdz_Vector* pIntVector = mdz_vector_create(sizeof(int)); // create vector of int elements.

  // reserve 10 elements, set them into 20. After this Capacity and Size of vector is 10.
  
  int nInitValue = 20;
  bRet = mdz_vector_reserveAndInit(pIntVector, 10, &nInitValue); 
  
  // insert element 15 in front position
  
  int nInsertValue = 15;
  bRet = mdz_vector_insert(pVector, 0, &nInsertValue, 1);
  
  // append vector with { 25, 26, 27}
  
  mdz_Vector* pAppendVector = mdz_vector_create(sizeof(int));
  bRet = mdz_vector_reserve(pAppendVector, 3); // reserve 3 elements. After this Capacity is 3 and Size is 0
  pAppendVector->m_nSize = 3;
  
  ((int*) pAppendVector)[0] = 25; // set element of vector directly
  ((int*) pAppendVector)[1] = 26;
  ((int*) pAppendVector)[2] = 27;
 
  bRet = mdz_vector_insert(pVector, pVector->m_nSize - 1, pAppendVector->m_pData, pAppendVector->m_nSize);
  
  ...
  
  mdz_vector_destroy(&pVector);
  mdz_vector_destroy(&pIntVector);
  
  ...
}

Code Example (higher-level use)

This is an example above using CMdzVector C++ "wrapper":

#include <mdz_containers.h>
#include <MdzVector.h>

int main(int argc, char* argv[])
{
  mdz_containers_init("test-name", "test-surname", "test-email", "38e82738ff04abc00e939d69591815e1");
  
  CMdzVector<int> arrnVector; // initialize vector of int elements.

  // reserve 10 elements, set them into 20. After this Capacity and Size of vector is 10.
  
  bool bRet = arrnVector.reserveAndInit(10, 20);
  
  // insert element 15 in front position
  
  bRet = arrnVector.insert(0, 15);
  
  // append vector with { 25, 26, 27}
  
  CMdzVector<int> arrnAppendVector;
  bRet = arrnAppendVector.reserve(3); // reserve 3 elements. After this Capacity is 3 and Size is 0
  arrnAppendVector.setSizeDirect(3);

  arrnAppendVector.atUnconst(0) = 25; // set element of vector directly
  arrnAppendVector.atUnconst(1) = 26; // if you prefer operators, you could extend "wrapper" with operator [] for direct access
  arrnAppendVector.atUnconst(2) = 27;
 
  bRet = arrnVector.append(arrnAppendVector);
  
  ...
}

mdz_ascii Overview

Wiki: mdz_ascii Wiki
file: "mdz_ascii.h"

Please take a look at "mdz_ascii.h" file or mdz_ascii Wiki site for detailed functions descriptions.

mdz_wchar Overview

Wiki: mdz_wchar Wiki
file: "mdz_wchar.h"

Please take a look at "mdz_wchar.h" file or mdz_wchar Wiki site for detailed functions descriptions.

mdz_utf8 Overview

Wiki: mdz_utf8 Wiki
file: "mdz_utf8.h"

Please take a look at "mdz_utf8.h" file or mdz_utf8 Wiki site for detailed functions descriptions.

mdz_utf16 Overview

Wiki: mdz_utf16 Wiki
file: "mdz_utf16.h"

Please take a look at "mdz_utf16.h" file or mdz_utf16 Wiki site for detailed functions descriptions.

Licensing info

Use of mdz_containers library is regulated by license agreement in LICENSE.txt

Basically private non-commercial "test" usage is unrestricted. Commercial usage of library (incl. its source code) will be regulated by according license agreement.

Credits

Diana Pukhlitska - participation in writing unit-tests (VC++, Windows) and performance-tests (VC++, Windows)
Oleksiy Dzyubenko - participation in writing unit-tests (VC++, Windows)

You can’t perform that action at this time.