summaryrefslogtreecommitdiffstats
path: root/src/nem_ull.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nem_ull.c')
-rw-r--r--src/nem_ull.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/nem_ull.c b/src/nem_ull.c
index f08506b..6405fc2 100644
--- a/src/nem_ull.c
+++ b/src/nem_ull.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <stdio.h>
#include "nem_ull.h"
#include "structs.h"
#include "common.h"
@@ -16,6 +17,52 @@ struct front_item * nem_ull(struct data * d){
return begin;
}
+struct front_item * nem_ull_online_shuffle(struct data * d, int rand_i){
+ struct front_item * front;
+ struct front_item * ret_front;
+ struct front_item * it;
+ struct front_item * tmp;
+ struct front_item * jt;
+ int i;
+
+ ret_front = new_front_item(0,0,NULL,NULL);
+ front = new_front_item(0,0,NULL,NULL);
+
+ for(i=0;i<d->N;++i){
+ if (i == rand_i) {
+ shuffle_items(d, i);
+ }
+ front = nem_ull_step(front,d,i);
+
+ it = ret_front;
+ jt = front;
+ while(it != NULL && jt != NULL) {
+ if(it->i.p == jt->i.p && it->i.w == jt->i.w) {
+ jt = jt->next;
+ if(it->next == NULL) break;
+ it = it->next;
+ } else if(it->i.p < jt->i.p || (it->i.p == jt->i.p && it->i.w < jt->i.w)) {
+ if(it->next == NULL) break;
+ it = it->next;
+ } else if(it->i.p > jt->i.p || (it->i.p == jt->i.p && it->i.w > jt->i.w)) {
+ tmp = new_front_item(jt->i.p, jt->i.w, it->prev, it);
+ tmp->time = jt->time;
+ tmp->prev->next = tmp;
+ tmp->next->prev = tmp;
+ jt = jt->next;
+ }
+ }
+
+ for(; jt != NULL; jt = jt->next) {
+ it->next = new_front_item(jt->i.p, jt->i.w, it, NULL);
+ it->next->time = jt->time;
+ it = it->next;
+ }
+ }
+
+ return ret_front;
+}
+
struct front_item * nem_ull_step(struct front_item * b, struct data * d, int it){
unsigned long int i,l0t,l1t,n;
double pmax;