| Type | Description |
|---|---|
z__i8 |
Signed 8bit integer |
z__i16 |
Signed 16bit integer |
z__i32 |
Signed 32bit integer |
z__i64 |
Signed 64bit integer |
z__u8 |
Unsigned 8bit integer |
z__u16 |
Unsigned 16bit integer |
z__u32 |
Unsigned 32bit integer |
z__u64 |
Unsigned 64bit integer |
z__int |
Integer type system provides |
z__f32 |
Single Precision Floating Point |
z__f64 |
Double Precision Floating Point |
z__float |
Float type system provides |
z__bool |
Bool Type |
z__ptr |
Void Pointer |
| Type | Description |
|---|---|
z__Arr(T) |
Type-safe, User generated Array, of type 'T' |
z__<type>Arr |
Dynamic Array for specified Type |
z__Dynt |
Dynamic Array for Unknown or Non-primitive Type |
z__Irrg |
Dynamic Object Holder |
| Type | Description |
|---|---|
z__FxArr |
Fixed length Array (minimal) |
z__SxArr |
Fixed length Array, Contained in a Struct with const len and lenUsed |
| Type | Description |
|---|---|
z__Vector(T) |
Creates User defined Vector Type |
z__Vector2 |
2D Vector {x, y} |
z__Vector3 |
3D Vector {x, y, z} |
z__Vector4 |
4D Vector {x, y, z, w} |
z__Vint2 |
2D Integer Vector {x, y} |
z__Vint3 |
3D Integer Vector {x, y, z} |
z__Vint4 |
4D Integer Vector {x, y, z, w} |
| Type | Description |
|---|---|
z__vec2 |
2D Vector {x, y} |
z__vec3 |
3D Vector {x, y, z} |
z__vec4 |
4D Vector {x, y, z, w} |
z__ivec2 |
2D Integer Vector {x, y} |
z__ivec3 |
3D Integer Vector {x, y, z} |
z__ivec4 |
4D Integer Vector {x, y, z, w} |
| Type | Description |
|---|---|
z__mat2 |
2x2 matrix |
z__mat3 |
3x3 matrix |
z__mat4 |
4x4 matrix |
This Library Provides 3 types of Dynamic arrays
- Generic Type Array (any, typesafe).
- Unknown Type Array (any, type-unsafe) of similar size.
- Unknown Object Type Arrat (same as Unknown Type but every new value can be of differnt size and type)
Originally This library was meant to only provide 1 type of Arrays; Dynamic Unknown Type, which would work similarly to std::vector. Generic Type was added later in order to replace the type checking hassle with array types which people will often use like i32 or f32 arrays which are essential even in small projects.
ztypes Provides Arr types for all int and float types
z__<type>Arr is the basic format for defining an Array, such as z__i64Arr means a singned 64bit integer Array.
You can Also Create your own type using z__Arr(T). See [Dispatching Types](# Dispatching Types)
ztypes Library also provides some funtions for Creating and Manupulating Arr types, NOTE the basic structure of types is same except for types names so macro functions are used in some cases.
Create a initializes Array of and of size and Returns it.
USAGE
z__<type>Arr z__<type>Arr_new(z__u32 <len>);
z__i8Arr i8_array = z__i8Arr_new(32);Delete a Arr type
z__Arr_delete(arr);
z__Arr_delete_(i8_array);
z__Arr_delete_(f32_array);Push Value At top Reallocates the Array if No more space is Availiable
z__<type>Arr_push(<type>Arr \*array ,<type> value);
z__i16Arr_push(array, 9);Deletes the top Value Reallocates the Array if Unused space is are more than gross limit
z__<type>Arr_pop(array);
z__u64_pop(array);A array which enables for quick initialization of array for non-standard types.
To initialize a Dynamic Unknown Type Array z__Dynt is used.
Create a initializes Array of and of size with a given Comment for the type and Returns it.
USAGE
z__Dynt_new(z__type type, z__u32 len, const char *comment, z__i32 commentLength);
typedef struct _objecttype
{
z__u8 info;
z__u32 len
z__Vector3 pos;
}object;
z__Dynt object_box = z__Dynt_new(z__typeof(object), 32, "Object:Box", -1);Delete a Dynt type and frees its comment if you dont want it be free set nameFree to False or 0.
USAGE
z__Dynt_delete(z__Dynt* arrt, z__bool nameFree);
z__Dynt_delete(&object_box, true);Pushes Value At top Reallocates the Array if No more space is Availiable
USAGE
z__Dynt_push( z__Dynt *arrt, void *val);
z__Dynt_push( &object_box, (object){2, 1, (z__Vector3){0, 3 ,0}});Delete the top Value Reallocates the Array if Unused space is are more than gross limit
USAGE
z__Dynt_pop( z__Dynt *arrt);Resizing array. Note: If array was larger then all values b/w oldsize and newsize is gone
USAGE
z__Dynt_resize(object_box, 23);Creates a New copy arrt and returns it. NOTE: New Copy is not linked with the passed value so its safe to delete it
USAGE
z__Dynt_makeCopy(const z__Dynt arrt);Unlike Dynt where type and single value size of an the entire array if fixed, We can create a Array type that will hold all irregulars objects and with every value pushed you need to specify the size or type of object;
To Create a Irregular Array type use z__Irrg typedef
z__Irrg newVar; // Creating a new variable
newVar = z__Irrg_new(10); // Initializes type with empty space allocated
z__Irrg_delete(&newVar) // Dealloctes All the conetents in holdingztypes also provides for you to define your own types.
Using z__Arr(T) macro lets you define your own Array type, Here 'T' is the type the array is going to hold
To Create Your own type just do
typedef z__Arr(/*YourType*/) newArray;
newArray Var1, Var2;
z__Arr_new(&Var1);
z__Arr_new(&Var2);Or you can Create a one time array without declaring a whole new type
z__Arr(/*YourType*/) Var1, Var2;
z__Arr_new(&Var1);
z__Arr_new(&Var2);
// No new type is createdFunctions
z__Arr(T) Provides some generic funtions for Array Manipulation
z__Arr_new(arr); // Create A new Array
z__Arr_delete(arr); // Delete The Array
z__Arr_push(arr, Val); // Push a new Value at Top
z__Arr_resize(arr, newsize); // Resize The Array
z__Arr_pop(arr); // Delete A Value From top
z__Arr_getTop(arr); // Get The Value from Top
z__Arr_getUsed(arr); // Get Length Used
z__Arr_getLen(arr); // Get Total Length Allocated
z__Arr_getVal(arr, index); // Access Value from an IndexNOTE: These FUCTIONS ARE COMPATITBLE WITH Pre-Defined Array Types BUT ONLY get FUNTIONS ARE COMPATIBLE WITH only z__SxArr Fixed Length Arrays Type, whilst z__FxArr is not
Dynamic Arrays are heap allocated; They are needed to be deleted once they are no longer needed, otherwise it will cause a memory leak.
There are two types of Fixed length arrays
- z__FxArr(T, sz, N): Equivalent to
foo bar[size] - z__SxArr(T, sz, N): Initializes a Struct with Attributes of
z__Arr(T)
Using FxArr is really straight forward.
z__FxArr(/*YourType*/, /*Length*/, /*Name*/);
/********************************************/
z__FxArr(int, 10, list); // Creates a Fixed Array named 'list' of length 10 holding capacity of 10 ints
list[9] = 3; // Changing Value
/* You can Also Create a Type Defination */
typedef z__FxArr(float, 3, vec3);
vec3 position = {1.0f, 1.0f, 0.0f};Fixed Length Arrays are Stack allocated.
z__SxArr Holds objects other than just array data similar to Dynamic Array. Infact z__SxArr types can use z__Arr_get... functions but only those function. Using Other than that will break the program as they are oriented towards dynamic memory allocation on Heap.
z__SxArr provides two functions and few definitions
z__SxArrI(/*YourType*/, /*Length*/, /*Name*/); // Create a new object of fixed length array
/********************************************/
z__SxArrI(int, 55, foo); // Creates a new Variable object 'foo' holding Fixed Length array
typedef z__SxArrDef(int, size) newType; // Creates a type of Fixed Length Array of type `int` holding 10 value capacity
z__SxArr(newType, Val); // Creates a New Variable of type 'newType'
z__SxArr_push(arr, val); // Push value at top
z__SxArr_pop(arr); // Deletes Value From TopWe can also init our own vector type with z__Vector(T).
Here is how it works
z__Vector(/*YourType*/, /*Members*/) NewTypeValue;
typedef z__Vector(/*YourType*/, /*Members*/) NewType;
/********************************************/
z__Vector(double, w, z, y) newVal;
newVal.w = 89.023f;
newVal.y = 77;
typedef z__Vector(double, w, z, y) newTypeV;
newTypeV tmpData = {
.w = 10f,
.z = 244.078f,
.y = 3.14f
};Vectors Are Stack Allocated
In ztypes the Linked Lists are comes with bare-bones template for type defination, with handful of funtions.
First we have to create our data structure with z__LinkStruct
z__Link(
<tagName>
, <mainDataType>
, <optionalMembers>); // Creating a Link list compactible Structure
// with tag name given by the user
z__LList(<tagName>, <optionalMembers>) varName; // Create The link list VariableOr we can use typedef to create a new type
typedef z__LList(<tagName>, <optionalMembers>) TypeName; // Create The link list Type
TypeName newVar; // Creates A new Variable of type TypeName;There is Also a way to create a one use Variable for temporary use
Below creates a node resembling link list Structure of tagName
z__LinkDef(<tagName>) varName; // Creates A new variable holding structure of LinkStruct.This Type also comes with its own set of fuctions for doing basic stuff
z__Link_new(<z__LList>); // Initializes Linked List
z__Link_delete(<z__LList>); // Deletes Initialized List
z__Link_pushHead(<z__LList>, <Data>); // Creates a new space for head pushes data, links with previous head
z__Link_popHead(<z__LList>); // Frees Head, sets previous link to head as new head;
z__Link_iprev(<z__LList>, n); // Go backwards in List (n) times, stops if at tail end.
z__Link_inext(<z__LList>, n); // Go forwards in List (n) times, stops if at head end.This library is not perfect and I know there are many others like it, but this one is mine.