194 lines
2.7 KiB
C
194 lines
2.7 KiB
C
|
|
/*
|
||
|
|
* This file is automaticaly generated, Please dont edit this file!
|
||
|
|
*/
|
||
|
|
#include <engine/floatArray.h>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
int floatArray_length( floatArray * this ) {
|
||
|
|
|
||
|
|
return this->total;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
float floatArray_get( floatArray * this, int index ) {
|
||
|
|
|
||
|
|
if ( index >= 0 && index < this->total ){
|
||
|
|
|
||
|
|
return this->items[index];
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
return NULL;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void floatArray_set( floatArray * this, int index, float item ) {
|
||
|
|
|
||
|
|
if ( index >= 0 && index < this->total ){
|
||
|
|
|
||
|
|
this->items[ index ] = item;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void floatArray_resize( floatArray * this, int capacity ) {
|
||
|
|
|
||
|
|
float * items = realloc( this->items, sizeof( float ) * capacity );
|
||
|
|
|
||
|
|
|
||
|
|
this->items = items;
|
||
|
|
|
||
|
|
this->capacity = capacity;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void floatArray_addVector2( floatArray * this, struct vector2 * item ) {
|
||
|
|
|
||
|
|
floatArray_add( this, item->x );
|
||
|
|
|
||
|
|
floatArray_add( this, item->y );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void floatArray_addVector3( floatArray * this, struct vector3 * item ) {
|
||
|
|
|
||
|
|
floatArray_add( this, item->x );
|
||
|
|
|
||
|
|
floatArray_add( this, item->y );
|
||
|
|
|
||
|
|
floatArray_add( this, item->z );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void floatArray_add( floatArray * this, float item ) {
|
||
|
|
|
||
|
|
if ( this->capacity == this->total ){
|
||
|
|
|
||
|
|
floatArray_resize( this, this->capacity * 2 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
this->items[ this->total++ ] = item;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void floatArray_delete( floatArray * this, int index ) {
|
||
|
|
if ( index < 0 || index >= this->total ){
|
||
|
|
|
||
|
|
return;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
this->items[index] = NULL;
|
||
|
|
|
||
|
|
for ( int i = index; i < this->total - 1; i++ ) {
|
||
|
|
|
||
|
|
this->items[i] = this->items[i + 1];
|
||
|
|
|
||
|
|
this->items[i + 1] = NULL;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
this->total--;
|
||
|
|
|
||
|
|
if ( this->total > 0 && this->total == this->capacity / 4 ){
|
||
|
|
|
||
|
|
floatArray_resize( this, this->capacity / 2 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
int floatArray_array_push( floatArray * this, float item ) {
|
||
|
|
|
||
|
|
floatArray_add( this, item );
|
||
|
|
|
||
|
|
return this->total;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void floatArray_unshift( floatArray * this, float item ) {
|
||
|
|
|
||
|
|
int length = this->total;
|
||
|
|
|
||
|
|
this->total++;
|
||
|
|
|
||
|
|
if ( this->capacity == this->total ){
|
||
|
|
|
||
|
|
floatArray_resize( this, this->capacity * 2 );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
for ( int i = length - 1; i >= 0; --i ) {
|
||
|
|
|
||
|
|
this->items[ i + 1 ] = this->items[ i ];
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
this->items[ 0 ] = item;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
float floatArray_pop( floatArray * this ) {
|
||
|
|
|
||
|
|
int length = this->total;
|
||
|
|
|
||
|
|
int lastIndex = length - 1;
|
||
|
|
|
||
|
|
float lastItem = floatArray_get( this, lastIndex );
|
||
|
|
|
||
|
|
floatArray_delete( this, lastIndex );
|
||
|
|
|
||
|
|
return lastItem;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
floatArray floatArray_new() {
|
||
|
|
|
||
|
|
floatArray instance;
|
||
|
|
|
||
|
|
instance.capacity = 10;
|
||
|
|
|
||
|
|
instance.total = 0;
|
||
|
|
|
||
|
|
instance.items = malloc( 10000000 );
|
||
|
|
|
||
|
|
return instance;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
floatArray * floatArray_newPointer() {
|
||
|
|
|
||
|
|
struct floatArray * pointer = malloc( sizeof ( struct floatArray ) );
|
||
|
|
|
||
|
|
pointer->capacity = 10;
|
||
|
|
|
||
|
|
pointer->total = 0;
|
||
|
|
|
||
|
|
pointer->items = malloc( 10000000 );
|
||
|
|
|
||
|
|
return pointer;
|
||
|
|
|
||
|
|
}
|
||
|
|
|