Skip to content

PetersSharp/Fast-Swap-for-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

113 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast Swap for C

Github releases Documentation Status Manual Build Status codecov.io Coverage Status Code Climate

Fast swap for C, any types to any types (gcc required), use only the header file fswap.h.

A functional combine producing swap objects of any types.

  • Automatic calculation of the size of the item to be exchanged (swapped)
  • Check the dimension of both elements.
  • Checking the identity of both elements.
  • High speed of data processing.
  • Support C99 and above.

Using

To connect to your project, you need to declare a one header file:

#include "fswap.h"

Call swap method:

/* obj1, obj2 - any C types. */
__swap_fast(obj1, obj2);

Add new types

If you use own structures in an array format, you will need to add their description to fswap.h, example:

 __builtin_choose_expr( \
   __builtin_types_compatible_p(__typeof__(A), struct my_struct[]), __swap_p(A, B, sizeof(A), sizeof(B)), \

Support types

Array full size swap types:
int[] const int[] unsigned int[] const unsigned int[]
short[] const short[] unsigned short[] const unsigned short[]
long[] const long[] unsigned long[] const unsigned long[]
long long[] const long long[] unsigned long long[] unsigned const long long[]
char[] const char[] unsigned char[] const unsigned char[]
Swap only pointer, types:
char* const char* unsigned char* const unsigned char*
void* const void* void*[] const void*[]
Full size swap types:
all other pointer C types

Inspire: ru.stackoverflow.com
OnLine example: coliru.stacked-crooked.com
Git repository: github
Web: home
Docs: readthedocs
Man: manual(3)

About

Fast swap for C

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors