summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlexandre Jesus <adbjesus@gmail.com>2016-08-22 16:35:31 +0100
committerAlexandre Jesus <adbjesus@gmail.com>2016-08-22 16:35:31 +0100
commit3c8f9385498611df123d5f07d0e52035b568d415 (patch)
tree790528ae70db81429d6cec0fd7892ac130535d7b /include
parent66cfb031dfa81fcb083335a709cb4bd561faccb2 (diff)
downloadlibuknapsack-3c8f9385498611df123d5f07d0e52035b568d415.tar.gz
libuknapsack-3c8f9385498611df123d5f07d0e52035b568d415.zip
Initial code
Diffstat (limited to 'include')
-rw-r--r--include/common.h19
-rw-r--r--include/nem_ull.h9
-rw-r--r--include/structs.h20
3 files changed, 48 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
new file mode 100644
index 0000000..c61ac4d
--- /dev/null
+++ b/include/common.h
@@ -0,0 +1,19 @@
+#ifndef _COMMON_H
+#define _COMMON_H
+
+#include "structs.h"
+
+#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+
+struct data * input(char[]);
+void print_data(struct data *);
+void print_front(struct front_item *);
+void free_data(struct data *);
+void free_front(struct front_item *);
+struct front_item * new_front_item(double, double, struct front_item *, struct front_item *);
+double dist_items(struct item *, struct item *);
+int len_front(struct front_item *);
+int cmp_items_ratio(const void * a, const void * b);
+
+#endif
diff --git a/include/nem_ull.h b/include/nem_ull.h
new file mode 100644
index 0000000..fd1b829
--- /dev/null
+++ b/include/nem_ull.h
@@ -0,0 +1,9 @@
+#ifndef _NEM_ULL_H
+#define _NEM_ULL_H
+
+#include "structs.h"
+
+struct front_item * nem_ull(struct data *);
+struct front_item * nem_ull_step(struct front_item *, struct data *, int);
+
+#endif
diff --git a/include/structs.h b/include/structs.h
new file mode 100644
index 0000000..cb1bca9
--- /dev/null
+++ b/include/structs.h
@@ -0,0 +1,20 @@
+#ifndef _STRUCTS_H
+#define _STRUCTS_H
+struct item {
+ double p;
+ double w;
+};
+
+struct data {
+ long int N;
+ struct item * items;
+ double allp;
+ double allw;
+};
+
+struct front_item {
+ struct item i;
+ struct front_item * next;
+ struct front_item * prev;
+};
+#endif