Initial commit
This commit is contained in:
182
application/demos/example.opengl/engine/unsignedIntegerArray.c
Normal file
182
application/demos/example.opengl/engine/unsignedIntegerArray.c
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* This file is automaticaly generated, Please dont edit this file!
|
||||
*/
|
||||
#include <engine/unsignedIntegerArray.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int unsignedIntegerArray_length( unsignedIntegerArray * this ) {
|
||||
|
||||
return this->total;
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsigned int unsignedIntegerArray_get( unsignedIntegerArray * this, int index ) {
|
||||
|
||||
return this->items[index];
|
||||
|
||||
}
|
||||
|
||||
|
||||
void unsignedIntegerArray_set( unsignedIntegerArray * this, int index, unsigned int item ) {
|
||||
|
||||
if ( index >= 0 && index < this->total ){
|
||||
|
||||
this->items[ index ] = item;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void unsignedIntegerArray_resize( unsignedIntegerArray * this, int capacity ) {
|
||||
|
||||
int * items = realloc( this->items, sizeof( int ) * capacity );
|
||||
|
||||
|
||||
this->items = items;
|
||||
|
||||
this->capacity = capacity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void unsignedIntegerArray_addVector2( unsignedIntegerArray * this, struct vector2 * item ) {
|
||||
|
||||
unsignedIntegerArray_add( this, item->x );
|
||||
|
||||
unsignedIntegerArray_add( this, item->y );
|
||||
|
||||
}
|
||||
|
||||
void unsignedIntegerArray_addVector3( unsignedIntegerArray * this, struct vector3 * item ) {
|
||||
|
||||
unsignedIntegerArray_add( this, item->x );
|
||||
|
||||
unsignedIntegerArray_add( this, item->y );
|
||||
|
||||
unsignedIntegerArray_add( this, item->z );
|
||||
|
||||
}
|
||||
|
||||
void unsignedIntegerArray_add( unsignedIntegerArray * this, unsigned int item ) {
|
||||
|
||||
if ( this->capacity == this->total ){
|
||||
|
||||
unsignedIntegerArray_resize( this, this->capacity * 2 );
|
||||
|
||||
}
|
||||
|
||||
this->items[ this->total++ ] = item;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void unsignedIntegerArray_delete( unsignedIntegerArray * this, int index ) {
|
||||
if ( index < 0 || index >= this->total ){
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
this->items[index] = 0.0;
|
||||
|
||||
for ( int i = index; i < this->total - 1; i++ ) {
|
||||
|
||||
this->items[i] = this->items[i + 1];
|
||||
|
||||
this->items[i + 1] = 0.0;
|
||||
|
||||
}
|
||||
|
||||
this->total--;
|
||||
|
||||
if ( this->total > 0 && this->total == this->capacity / 4 ){
|
||||
|
||||
unsignedIntegerArray_resize( this, this->capacity / 2 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsigned int unsignedIntegerArray_array_push( unsignedIntegerArray * this, unsigned int item ) {
|
||||
|
||||
unsignedIntegerArray_add( this, item );
|
||||
|
||||
return this->total;
|
||||
|
||||
}
|
||||
|
||||
void unsignedIntegerArray_unshift( unsignedIntegerArray * this, int item ) {
|
||||
|
||||
int length = this->total;
|
||||
|
||||
this->total++;
|
||||
|
||||
if ( this->capacity == this->total ){
|
||||
|
||||
unsignedIntegerArray_resize( this, this->capacity * 2 );
|
||||
|
||||
}
|
||||
|
||||
for ( int i = length - 1; i >= 0; --i ) {
|
||||
|
||||
this->items[ i + 1 ] = this->items[ i ];
|
||||
|
||||
}
|
||||
|
||||
this->items[ 0 ] = item;
|
||||
|
||||
}
|
||||
|
||||
unsigned int unsignedIntegerArray_pop( unsignedIntegerArray * this ) {
|
||||
|
||||
int length = this->total;
|
||||
|
||||
int lastIndex = length - 1;
|
||||
|
||||
int lastItem = unsignedIntegerArray_get( this, lastIndex );
|
||||
|
||||
unsignedIntegerArray_delete( this, lastIndex );
|
||||
|
||||
return lastItem;
|
||||
|
||||
}
|
||||
|
||||
unsignedIntegerArray unsignedIntegerArray_new() {
|
||||
|
||||
unsignedIntegerArray instance;
|
||||
|
||||
instance.capacity = 10;
|
||||
|
||||
instance.total = 0;
|
||||
|
||||
instance.items = malloc( 10000000 );
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
unsignedIntegerArray * unsignedIntegerArray_newPointer() {
|
||||
|
||||
struct unsignedIntegerArray * pointer = malloc( sizeof ( struct unsignedIntegerArray ) );
|
||||
|
||||
pointer->capacity = 10;
|
||||
|
||||
pointer->total = 0;
|
||||
|
||||
pointer->items = malloc( 10000000 );
|
||||
|
||||
return pointer;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user