Fix several issues with includes and redundant comparisons.

This commit is contained in:
Danila Fedorin 2017-07-20 21:39:26 -07:00
parent 1b57ebb027
commit cd822fedfc
4 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#ifndef LIBDS_SPRS_HEADER #ifndef LIBDS_SPRS_HEADER
#define LIBDS_SPRS_HEADER #define LIBDS_SPRS_HEADER
#include <stddef.h>
#include "libds.h" #include "libds.h"
/** /**

View File

@ -3,6 +3,7 @@
#define LIBDS_VEC_CAPACITY 4 #define LIBDS_VEC_CAPACITY 4
#include <stddef.h>
#include "libds.h" #include "libds.h"
/** /**

View File

@ -38,7 +38,7 @@ void sprs_put(sprs* sprs, int index, void* data){
} }
} }
int sprs_contains(sprs* sprs, int index){ int sprs_contains(sprs* sprs, int index){
return index >= 0 && sprs->sparse[index].index >= 0 && sprs->sparse[index].index < sprs->size && sprs->dense[sprs->sparse[index].index] == index; return index >= 0 && sprs->sparse[index].index < sprs->size && sprs->dense[sprs->sparse[index].index] == index;
} }
void* sprs_get(sprs* sprs, int index){ void* sprs_get(sprs* sprs, int index){
void* data = NULL; void* data = NULL;

View File

@ -92,7 +92,7 @@ int vec_foreach(vec* v, void* data, compare_func compare, foreach_func foreach,
void* vec_index(vec* v, size_t index) { void* vec_index(vec* v, size_t index) {
void* to_return = NULL; void* to_return = NULL;
if (index < v->capacity && index >= 0) { if (index < v->capacity) {
to_return = ((void**) v->data)[index]; to_return = ((void**) v->data)[index];
} }
return to_return; return to_return;