summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-02-03 22:20:35 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-02-03 22:20:35 +0100
commitee26b8ff850add4f83b912635a71dbde06f268d1 (patch)
treeada230a0d34aaf2a0e9fbecadde0bdf0dcdf1da4 /src/core
parent1dafef5fdf9d98b38cbe717b8a220d721f0ebea8 (diff)
Continuing Implementation...
Diffstat (limited to 'src/core')
-rw-r--r--src/core/index.c16
-rw-r--r--src/core/index.h2
-rw-r--r--src/core/index_types.h10
3 files changed, 25 insertions, 3 deletions
diff --git a/src/core/index.c b/src/core/index.c
index dc52d03..5c93ed3 100644
--- a/src/core/index.c
+++ b/src/core/index.c
@@ -64,3 +64,19 @@ ZoO_index ZoO_index_random_up_to (const ZoO_index max)
* ((float) max)
);
}
+
+int ZoO_index_cmp (const ZoO_index a, const ZoO_index b)
+{
+ if (a < b)
+ {
+ return -1;
+ }
+ else if (a > b)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
diff --git a/src/core/index.h b/src/core/index.h
index eb3c471..bd77cb4 100644
--- a/src/core/index.h
+++ b/src/core/index.h
@@ -21,4 +21,6 @@ ZoO_index ZoO_index_random (void);
@*/
ZoO_index ZoO_index_random_up_to (const ZoO_index limit);
+int ZoO_index_cmp (const ZoO_index a, const ZoO_index b);
+
#endif
diff --git a/src/core/index_types.h b/src/core/index_types.h
index 84a1e20..5514a2a 100644
--- a/src/core/index_types.h
+++ b/src/core/index_types.h
@@ -1,6 +1,8 @@
#ifndef _ZoO_CORE_INDEX_TYPES_H_
#define _ZoO_CORE_INDEX_TYPES_H_
+#include "../pervasive.h"
+
/*
* ZoO_index is a replacement for size_t. As many indices are stored for every
* word learned, having control over which type of variable is used to represent
@@ -8,6 +10,7 @@
*/
#include <limits.h>
+#include <stdint.h>
/* Must be unsigned. */
typedef unsigned int ZoO_index;
@@ -15,9 +18,10 @@ typedef unsigned int ZoO_index;
/* Must be > 0. */
#define ZoO_INDEX_MAX UINT_MAX
-
-#if (ZoO_INDEX_MAX > SIZE_MAX)
- #error "ZoO_index should not be able to go higher than a size_t variable."
+#ifndef ZoO_RUNNING_FRAMA_C
+ #if (ZoO_INDEX_MAX > SIZE_MAX)
+ #error "ZoO_index should not be able to go higher than a size_t variable."
+ #endif
#endif
#endif