nysol-take 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/mbiclique.rb +317 -0
- data/bin/mbipolish.rb +362 -0
- data/bin/mccomp.rb +235 -0
- data/bin/mclique.rb +295 -0
- data/bin/mclique2g.rb +105 -0
- data/bin/mcliqueInfo.rb +203 -0
- data/bin/mfriends.rb +202 -0
- data/bin/mgdiff.rb +252 -0
- data/bin/mhifriend.rb +456 -0
- data/bin/mhipolish.rb +465 -0
- data/bin/mitemset.rb +168 -0
- data/bin/mpal.rb +410 -0
- data/bin/mpolishing.rb +399 -0
- data/bin/msequence.rb +165 -0
- data/bin/mtra2g.rb +476 -0
- data/bin/mtra2gc.rb +360 -0
- data/ext/grhfilrun/extconf.rb +12 -0
- data/ext/grhfilrun/grhfilrun.c +85 -0
- data/ext/grhfilrun/src/_sspc.c +358 -0
- data/ext/grhfilrun/src/aheap.c +545 -0
- data/ext/grhfilrun/src/aheap.h +251 -0
- data/ext/grhfilrun/src/base.c +92 -0
- data/ext/grhfilrun/src/base.h +59 -0
- data/ext/grhfilrun/src/fstar.c +497 -0
- data/ext/grhfilrun/src/fstar.h +80 -0
- data/ext/grhfilrun/src/grhfil.c +214 -0
- data/ext/grhfilrun/src/itemset.c +713 -0
- data/ext/grhfilrun/src/itemset.h +170 -0
- data/ext/grhfilrun/src/problem.c +415 -0
- data/ext/grhfilrun/src/problem.h +179 -0
- data/ext/grhfilrun/src/queue.c +533 -0
- data/ext/grhfilrun/src/queue.h +182 -0
- data/ext/grhfilrun/src/sample.c +19 -0
- data/ext/grhfilrun/src/sspc.c +597 -0
- data/ext/grhfilrun/src/sspc2.c +491 -0
- data/ext/grhfilrun/src/stdlib2.c +1482 -0
- data/ext/grhfilrun/src/stdlib2.h +892 -0
- data/ext/grhfilrun/src/trsact.c +817 -0
- data/ext/grhfilrun/src/trsact.h +160 -0
- data/ext/grhfilrun/src/vec.c +745 -0
- data/ext/grhfilrun/src/vec.h +172 -0
- data/ext/lcmrun/extconf.rb +20 -0
- data/ext/lcmrun/lcmrun.cpp +99 -0
- data/ext/lcmrun/src/aheap.c +216 -0
- data/ext/lcmrun/src/aheap.h +111 -0
- data/ext/lcmrun/src/base.c +92 -0
- data/ext/lcmrun/src/base.h +59 -0
- data/ext/lcmrun/src/itemset.c +496 -0
- data/ext/lcmrun/src/itemset.h +157 -0
- data/ext/lcmrun/src/lcm.c +427 -0
- data/ext/lcmrun/src/problem.c +349 -0
- data/ext/lcmrun/src/problem.h +177 -0
- data/ext/lcmrun/src/queue.c +528 -0
- data/ext/lcmrun/src/queue.h +176 -0
- data/ext/lcmrun/src/sgraph.c +359 -0
- data/ext/lcmrun/src/sgraph.h +173 -0
- data/ext/lcmrun/src/stdlib2.c +1282 -0
- data/ext/lcmrun/src/stdlib2.h +823 -0
- data/ext/lcmrun/src/trsact.c +747 -0
- data/ext/lcmrun/src/trsact.h +159 -0
- data/ext/lcmrun/src/vec.c +731 -0
- data/ext/lcmrun/src/vec.h +171 -0
- data/ext/lcmseq0run/extconf.rb +20 -0
- data/ext/lcmseq0run/lcmseq0run.cpp +59 -0
- data/ext/lcmseq0run/src/aheap.c +216 -0
- data/ext/lcmseq0run/src/aheap.h +111 -0
- data/ext/lcmseq0run/src/base.c +92 -0
- data/ext/lcmseq0run/src/base.h +59 -0
- data/ext/lcmseq0run/src/itemset.c +518 -0
- data/ext/lcmseq0run/src/itemset.h +157 -0
- data/ext/lcmseq0run/src/itemset_zero.c +522 -0
- data/ext/lcmseq0run/src/lcm_seq.c +446 -0
- data/ext/lcmseq0run/src/lcm_seq_zero.c +446 -0
- data/ext/lcmseq0run/src/problem.c +439 -0
- data/ext/lcmseq0run/src/problem.h +179 -0
- data/ext/lcmseq0run/src/problem_zero.c +439 -0
- data/ext/lcmseq0run/src/queue.c +533 -0
- data/ext/lcmseq0run/src/queue.h +182 -0
- data/ext/lcmseq0run/src/stdlib2.c +1350 -0
- data/ext/lcmseq0run/src/stdlib2.h +864 -0
- data/ext/lcmseq0run/src/trsact.c +747 -0
- data/ext/lcmseq0run/src/trsact.h +159 -0
- data/ext/lcmseq0run/src/vec.c +779 -0
- data/ext/lcmseq0run/src/vec.h +172 -0
- data/ext/lcmseqrun/extconf.rb +20 -0
- data/ext/lcmseqrun/lcmseqrun.cpp +101 -0
- data/ext/lcmseqrun/src/aheap.c +216 -0
- data/ext/lcmseqrun/src/aheap.h +111 -0
- data/ext/lcmseqrun/src/base.c +92 -0
- data/ext/lcmseqrun/src/base.h +59 -0
- data/ext/lcmseqrun/src/itemset.c +518 -0
- data/ext/lcmseqrun/src/itemset.h +157 -0
- data/ext/lcmseqrun/src/itemset_zero.c +522 -0
- data/ext/lcmseqrun/src/lcm_seq.c +447 -0
- data/ext/lcmseqrun/src/lcm_seq_zero.c +446 -0
- data/ext/lcmseqrun/src/problem.c +439 -0
- data/ext/lcmseqrun/src/problem.h +179 -0
- data/ext/lcmseqrun/src/problem_zero.c +439 -0
- data/ext/lcmseqrun/src/queue.c +533 -0
- data/ext/lcmseqrun/src/queue.h +182 -0
- data/ext/lcmseqrun/src/stdlib2.c +1350 -0
- data/ext/lcmseqrun/src/stdlib2.h +864 -0
- data/ext/lcmseqrun/src/trsact.c +747 -0
- data/ext/lcmseqrun/src/trsact.h +159 -0
- data/ext/lcmseqrun/src/vec.c +779 -0
- data/ext/lcmseqrun/src/vec.h +172 -0
- data/ext/lcmtransrun/extconf.rb +18 -0
- data/ext/lcmtransrun/lcmtransrun.cpp +264 -0
- data/ext/macerun/extconf.rb +20 -0
- data/ext/macerun/macerun.cpp +57 -0
- data/ext/macerun/src/aheap.c +217 -0
- data/ext/macerun/src/aheap.h +112 -0
- data/ext/macerun/src/itemset.c +491 -0
- data/ext/macerun/src/itemset.h +158 -0
- data/ext/macerun/src/mace.c +503 -0
- data/ext/macerun/src/problem.c +346 -0
- data/ext/macerun/src/problem.h +174 -0
- data/ext/macerun/src/queue.c +529 -0
- data/ext/macerun/src/queue.h +177 -0
- data/ext/macerun/src/sgraph.c +360 -0
- data/ext/macerun/src/sgraph.h +174 -0
- data/ext/macerun/src/stdlib2.c +993 -0
- data/ext/macerun/src/stdlib2.h +811 -0
- data/ext/macerun/src/vec.c +634 -0
- data/ext/macerun/src/vec.h +170 -0
- data/ext/sspcrun/extconf.rb +20 -0
- data/ext/sspcrun/src/_sspc.c +358 -0
- data/ext/sspcrun/src/aheap.c +545 -0
- data/ext/sspcrun/src/aheap.h +251 -0
- data/ext/sspcrun/src/base.c +92 -0
- data/ext/sspcrun/src/base.h +59 -0
- data/ext/sspcrun/src/fstar.c +496 -0
- data/ext/sspcrun/src/fstar.h +80 -0
- data/ext/sspcrun/src/grhfil.c +213 -0
- data/ext/sspcrun/src/itemset.c +713 -0
- data/ext/sspcrun/src/itemset.h +170 -0
- data/ext/sspcrun/src/problem.c +415 -0
- data/ext/sspcrun/src/problem.h +179 -0
- data/ext/sspcrun/src/queue.c +533 -0
- data/ext/sspcrun/src/queue.h +182 -0
- data/ext/sspcrun/src/sample.c +19 -0
- data/ext/sspcrun/src/sspc.c +598 -0
- data/ext/sspcrun/src/sspc2.c +491 -0
- data/ext/sspcrun/src/stdlib2.c +1482 -0
- data/ext/sspcrun/src/stdlib2.h +892 -0
- data/ext/sspcrun/src/trsact.c +817 -0
- data/ext/sspcrun/src/trsact.h +160 -0
- data/ext/sspcrun/src/vec.c +745 -0
- data/ext/sspcrun/src/vec.h +172 -0
- data/ext/sspcrun/sspcrun.cpp +54 -0
- data/lib/nysol/enumLcmEp.rb +338 -0
- data/lib/nysol/enumLcmEsp.rb +284 -0
- data/lib/nysol/enumLcmIs.rb +275 -0
- data/lib/nysol/enumLcmSeq.rb +143 -0
- data/lib/nysol/items.rb +201 -0
- data/lib/nysol/seqDB.rb +256 -0
- data/lib/nysol/take.rb +39 -0
- data/lib/nysol/taxonomy.rb +113 -0
- data/lib/nysol/traDB.rb +257 -0
- metadata +239 -0
@@ -0,0 +1,529 @@
|
|
1
|
+
/* Library of queue: spped priority implementation
|
2
|
+
12/Apr/2001 by Takeaki Uno e-mail:uno@nii.jp,
|
3
|
+
homepage: http://research.nii.ac.jp/~uno/index.html */
|
4
|
+
/* This program is available for only academic use, basically.
|
5
|
+
Anyone can modify this program, but he/she has to write down
|
6
|
+
the change of the modification on the top of the source code.
|
7
|
+
Neither contact nor appointment to Takeaki Uno is needed.
|
8
|
+
If one wants to re-distribute this code, do not forget to
|
9
|
+
refer the newest code, and show the link to homepage of
|
10
|
+
Takeaki Uno, to notify the news about the codes for the users.
|
11
|
+
For the commercial use, please make a contact to Takeaki Uno. */
|
12
|
+
|
13
|
+
#ifndef _queue_c_
|
14
|
+
#define _queue_c_
|
15
|
+
|
16
|
+
|
17
|
+
#include"queue.h"
|
18
|
+
#include"stdlib2.c"
|
19
|
+
|
20
|
+
QSORT_TYPE(QUEUE_INT, QUEUE_INT)
|
21
|
+
QSORT_TYPE(QUEUE_ID, QUEUE_ID)
|
22
|
+
QUEUE INIT_QUEUE = {TYPE_QUEUE,NULL,0,0,0};
|
23
|
+
QUEUE_INT *common_QUEUE_INTp;
|
24
|
+
|
25
|
+
/* initialization, not fill the memory by 0 */
|
26
|
+
void QUEUE_alloc (QUEUE *Q, QUEUE_ID siz){
|
27
|
+
*Q = INIT_QUEUE;
|
28
|
+
Q->end = siz+1;
|
29
|
+
malloc2 (Q->v, siz+1, EXIT);
|
30
|
+
}
|
31
|
+
|
32
|
+
/* termination processing */
|
33
|
+
void QUEUE_end (QUEUE *Q){
|
34
|
+
free2 (Q->v);
|
35
|
+
*Q = INIT_QUEUE;
|
36
|
+
}
|
37
|
+
|
38
|
+
/* tranpose the matrix ; counting/transpose/memory_allocate */
|
39
|
+
void QUEUE_delivery(QUEUE *OQ, VEC_ID *c, QUEUE *jump, QUEUE *Q, QUEUE *occ, VEC_ID t, QUEUE_INT M){ VEC_ID i, e;
|
40
|
+
QUEUE_INT *x;
|
41
|
+
FLOOP(i, 0, occ? occ->t: t){
|
42
|
+
e = occ? occ->v[i]: i;
|
43
|
+
if ( c ){
|
44
|
+
if ( jump ){ MLOOP (x, Q[e].v, M){ if ( c[*x]==0 ) ARY_INS (*jump, *x); c[*x]++; }
|
45
|
+
} else { MLOOP (x, Q[e].v, M){ c[*x]++; }}
|
46
|
+
} else {
|
47
|
+
if ( jump ){ MLOOP (x, Q[e].v, M){ if ( OQ[*x].t==0 ) ARY_INS (*jump, *x); ARY_INS (OQ[*x], e); }
|
48
|
+
} else MLOOP (x, Q[e].v, M){ ARY_INS (OQ[*x], e); }
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
/* sort a QUEUE with WEIGHT, with already allocated memory */
|
54
|
+
void QUEUE_perm_WEIGHT (QUEUE *Q, WEIGHT *w, PERM *invperm, int flag){
|
55
|
+
WEIGHT y;
|
56
|
+
if ( w ){
|
57
|
+
qsort_perm__QUEUE_INT (Q->v, Q->t, invperm, flag);
|
58
|
+
ARY_INVPERMUTE_ (w, invperm, y, Q->t);
|
59
|
+
}
|
60
|
+
qsort_QUEUE_INT (Q->v, Q->t, flag);
|
61
|
+
}
|
62
|
+
|
63
|
+
/* remove (or unify) the consecutive same ID's in a QUEUE (duplication delete, if sorted) */
|
64
|
+
void QUEUE_rm_dup_WEIGHT (QUEUE *Q, WEIGHT *w){
|
65
|
+
VEC_ID j, jj=0;
|
66
|
+
if ( w ){
|
67
|
+
FLOOP (j, 1, Q->t){
|
68
|
+
if ( Q->v[j-1] != Q->v[j] ){
|
69
|
+
Q->v[++jj] = Q->v[j];
|
70
|
+
w[jj] = w[j];
|
71
|
+
} else w[jj] += w[j];
|
72
|
+
}
|
73
|
+
} else FLOOP (j, 1, Q->t){
|
74
|
+
if ( Q->v[j-1] != Q->v[j] ) Q->v[++jj] = Q->v[j];
|
75
|
+
}
|
76
|
+
if ( Q->t>0 ) Q->t = jj+1;
|
77
|
+
}
|
78
|
+
|
79
|
+
/***********************************************************************/
|
80
|
+
/* duplicate occ's in jump, ( copy occ's to allocated QUEUE array) */
|
81
|
+
/* Q[i].end := original item, clear each original occ */
|
82
|
+
/* buffer size is multiplied by u */
|
83
|
+
/*******************************************************/
|
84
|
+
void QUEUE_occ_dup (QUEUE *jump, QUEUE **QQ, QUEUE *Q, WEIGHT **ww, WEIGHT *w, WEIGHT **ppw, WEIGHT *pw, int u){
|
85
|
+
QUEUE_ID i, l=QUEUE_LENGTH_(*jump);
|
86
|
+
size_t cnt=0;
|
87
|
+
QUEUE_INT e, *x;
|
88
|
+
char *buf;
|
89
|
+
int unit = sizeof(*Q) + (w?sizeof(*w):0) + (pw?sizeof(*pw):0);
|
90
|
+
|
91
|
+
ENMAX (u, sizeof(*x));
|
92
|
+
MQUE_FLOOP (*jump, x) cnt += Q[*x].t;
|
93
|
+
if ( cnt == 0 ){ *QQ=NULL; return; }
|
94
|
+
malloc2 (buf, l*unit + (cnt+l)*u, EXIT);
|
95
|
+
*QQ = (QUEUE*)buf; buf += sizeof(*Q) *l;
|
96
|
+
if ( w ){ *ww = (WEIGHT *)buf; buf += sizeof(*w)*l; }
|
97
|
+
if ( pw ){ *ppw = (WEIGHT *)buf; buf += sizeof(*pw)*l; }
|
98
|
+
for (i=0 ; i<jump->t ; i++){
|
99
|
+
e = jump->v[i];
|
100
|
+
(*QQ)[i].end = e;
|
101
|
+
(*QQ)[i].v = (QUEUE_INT *)buf;
|
102
|
+
(*QQ)[i].t = Q[e].t;
|
103
|
+
memcpy (buf, Q[e].v, (Q[e].t+1)*u);
|
104
|
+
buf += (Q[e].t+1) *u;
|
105
|
+
if ( w ) (*ww)[i] = w[e];
|
106
|
+
if ( pw ) (*ppw)[i] = pw[e];
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
/* return the position of the first element having value e. return -1 if no such element exists */
|
112
|
+
LONG QUEUE_ele (QUEUE *Q, QUEUE_INT e){
|
113
|
+
QUEUE_INT *x;
|
114
|
+
MQUE_FLOOP (*Q, x)
|
115
|
+
if ( *x == e ) return (x - Q->v);
|
116
|
+
return (-1);
|
117
|
+
}
|
118
|
+
|
119
|
+
/* insert an element to the tail */
|
120
|
+
void QUEUE_ins_ (QUEUE *Q, QUEUE_INT e){
|
121
|
+
Q->v[Q->t] = e;
|
122
|
+
Q->t++;
|
123
|
+
}
|
124
|
+
void QUEUE_ins (QUEUE *Q, QUEUE_INT e){
|
125
|
+
Q->v[Q->t] = e;
|
126
|
+
QUEUE_INCREMENT (*Q, Q->t);
|
127
|
+
if (Q->s == Q->t ) error_num ("QUEUE_ins: overflow", Q->s, EXIT);
|
128
|
+
}
|
129
|
+
|
130
|
+
/* insert an element to the head */
|
131
|
+
void QUEUE_ins_head_ (QUEUE *Q, QUEUE_INT e){
|
132
|
+
Q->s--;
|
133
|
+
Q->v[Q->s] = e;
|
134
|
+
}
|
135
|
+
void QUEUE_ins_head (QUEUE *Q, QUEUE_INT e){
|
136
|
+
QUEUE_DECREMENT(*Q,Q->s);
|
137
|
+
Q->v[Q->s] = e;
|
138
|
+
if (Q->s == Q->t ) error_num ("QUEUE_ins_head: underflow", Q->s, EXIT);
|
139
|
+
}
|
140
|
+
|
141
|
+
/* extract an element from the head, without checking underflow */
|
142
|
+
QUEUE_INT QUEUE_ext_ (QUEUE *Q){
|
143
|
+
(Q->s)++;
|
144
|
+
return (Q->v[Q->s-1]);
|
145
|
+
}
|
146
|
+
QUEUE_INT QUEUE_ext (QUEUE *Q){
|
147
|
+
QUEUE_INT e;
|
148
|
+
if (Q->s == Q->t ) error_num ("QUEUE_ext: empty queue", Q->s, EXIT0);
|
149
|
+
e = Q->v[Q->s];
|
150
|
+
QUEUE_INCREMENT(*Q,Q->s);
|
151
|
+
return ( e);
|
152
|
+
}
|
153
|
+
|
154
|
+
/* extract an element from the tail, without checking underflow */
|
155
|
+
QUEUE_INT QUEUE_ext_tail_ (QUEUE *Q){
|
156
|
+
(Q->t)--;
|
157
|
+
return (Q->v[Q->t]);
|
158
|
+
}
|
159
|
+
QUEUE_INT QUEUE_ext_tail (QUEUE *Q){
|
160
|
+
if ( Q->s == Q->t ) error_num ("QUEUE_ext_tail: empty queue", Q->s, EXIT0);
|
161
|
+
QUEUE_DECREMENT(*Q,Q->t);
|
162
|
+
return (Q->v[Q->t]);
|
163
|
+
}
|
164
|
+
|
165
|
+
/* remove the j-th element and replace it by the tail */
|
166
|
+
void QUEUE_rm_ (QUEUE *Q, QUEUE_ID j){
|
167
|
+
Q->t--;
|
168
|
+
Q->v[j] = Q->v[Q->t];
|
169
|
+
}
|
170
|
+
void QUEUE_rm (QUEUE *Q, QUEUE_ID j){
|
171
|
+
if ( Q->s <= Q->t ){
|
172
|
+
if ( j < Q->s || j >= Q->t ) error ("QUEUE_rm: j is out of queue", EXIT);
|
173
|
+
} else if ( j < Q->s && j >= Q->t ) error ("QUEUE_rm: j is out of queue", EXIT);
|
174
|
+
QUEUE_DECREMENT(*Q,Q->t);
|
175
|
+
Q->v[j] = Q->v[Q->t];
|
176
|
+
}
|
177
|
+
|
178
|
+
/* remove the j-th element and replace it by the head */
|
179
|
+
void QUEUE_rm_head_ (QUEUE *Q, QUEUE_ID j){
|
180
|
+
Q->v[j] = Q->v[Q->s];
|
181
|
+
Q->s++;
|
182
|
+
}
|
183
|
+
void QUEUE_rm_head (QUEUE *Q, QUEUE_ID j){
|
184
|
+
if ( Q->s <= Q->t ){
|
185
|
+
if ( j < Q->s || j >= Q->t ) error ("QUEUE_rm: j is out of queue", EXIT);
|
186
|
+
} else if ( j < Q->s && j >= Q->t ) error ("QUEUE_rm: j is out of queue", EXIT);
|
187
|
+
Q->v[j] = Q->v[Q->s];
|
188
|
+
QUEUE_INCREMENT(*Q,Q->s);
|
189
|
+
}
|
190
|
+
|
191
|
+
/* remove the j-th element and shift the following elements to fill the gap */
|
192
|
+
int QUEUE_rm_ele_ (QUEUE *Q, QUEUE_INT e){
|
193
|
+
QUEUE_ID i;
|
194
|
+
QUEUE_F_LOOP (*Q, i){
|
195
|
+
if ( Q->v[i] == e ){
|
196
|
+
memcpy ( &(Q->v[i]), &(Q->v[i+1]), (Q->t-i-1)*sizeof(QUEUE_INT));
|
197
|
+
Q->t--;
|
198
|
+
return (1);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
return (0);
|
202
|
+
}
|
203
|
+
/* insert e to the position determined by the increasing order of elements */
|
204
|
+
void QUEUE_ins_ele_ (QUEUE *Q, QUEUE_INT e){
|
205
|
+
QUEUE_ID i;
|
206
|
+
QUEUE_INT ee;
|
207
|
+
QUEUE_BE_LOOP_ (*Q, i, ee){
|
208
|
+
if ( ee<e ) break;
|
209
|
+
Q->v[i+1] = ee;
|
210
|
+
}
|
211
|
+
Q->v[i+1] = e;
|
212
|
+
Q->t++;
|
213
|
+
}
|
214
|
+
|
215
|
+
/* Append Q2 to the tail of Q1. Q2 will not be deleted */
|
216
|
+
void QUEUE_concat_ (QUEUE *Q1, QUEUE *Q2){
|
217
|
+
memcpy ( &(Q1->v[Q1->t]), &(Q2->v[Q2->s]), (Q2->t-Q2->s)*sizeof(QUEUE_INT));
|
218
|
+
Q1->t += Q2->t-Q2->s;
|
219
|
+
}
|
220
|
+
void QUEUE_concat (QUEUE *Q1, QUEUE *Q2){
|
221
|
+
QUEUE_ID e = Q2->s;
|
222
|
+
while ( e != Q2->t){
|
223
|
+
QUEUE_ins (Q1, Q2->v[e]);
|
224
|
+
QUEUE_INCREMENT(*Q2,e);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
/* Append Q2 to the tail of Q1. Q2 will be deleted */
|
228
|
+
void QUEUE_append_ (QUEUE *Q1, QUEUE *Q2){
|
229
|
+
QUEUE_concat_ (Q1, Q2);
|
230
|
+
QUEUE_RMALL (*Q2);
|
231
|
+
}
|
232
|
+
void QUEUE_append (QUEUE *Q1, QUEUE *Q2){ // more improvement can be
|
233
|
+
while ( Q2->s != Q2->t )
|
234
|
+
QUEUE_ins (Q1, QUEUE_ext(Q2));
|
235
|
+
}
|
236
|
+
|
237
|
+
/* Append from j to jj th elements to the tail of Q1. Q2 will not be deleted */
|
238
|
+
void QUEUE_subconcat_ (QUEUE *Q1, QUEUE *Q2, QUEUE_ID j, QUEUE_ID jj){
|
239
|
+
for ( ; j<=jj ; j++){
|
240
|
+
Q1->v[Q1->t] = Q2->v[j];
|
241
|
+
Q1->t++;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
void QUEUE_subconcat (QUEUE *Q1, QUEUE *Q2, QUEUE_ID j, QUEUE_ID jj){
|
245
|
+
while (1){
|
246
|
+
QUEUE_ins (Q1, Q2->v[j]);
|
247
|
+
if ( j == jj ) break;
|
248
|
+
QUEUE_INCREMENT(*Q2,j);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
/* initialize Q1 by length of Q2, and copy Q2 to Q1 */
|
253
|
+
void QUEUE_store_ (QUEUE *Q1, QUEUE *Q2){
|
254
|
+
QUEUE_alloc (Q1, QUEUE_LENGTH(*Q2));
|
255
|
+
QUEUE_concat_ (Q1, Q2);
|
256
|
+
}
|
257
|
+
void QUEUE_store (QUEUE *Q1, QUEUE *Q2){
|
258
|
+
QUEUE_alloc (Q1, QUEUE_LENGTH(*Q2));
|
259
|
+
QUEUE_concat (Q1, Q2);
|
260
|
+
}
|
261
|
+
/* copy Q2 to Q1 and delete Q2 */
|
262
|
+
void QUEUE_restore_ (QUEUE *Q1, QUEUE *Q2){
|
263
|
+
QUEUE_RMALL (*Q1);
|
264
|
+
QUEUE_concat_ (Q1, Q2);
|
265
|
+
QUEUE_end (Q2);
|
266
|
+
}
|
267
|
+
void QUEUE_restore (QUEUE *Q1, QUEUE *Q2){
|
268
|
+
QUEUE_RMALL (*Q1);
|
269
|
+
QUEUE_concat (Q1, Q2);
|
270
|
+
QUEUE_end (Q2);
|
271
|
+
}
|
272
|
+
|
273
|
+
/* copy Q2 to Q1 */
|
274
|
+
void QUEUE_cpy_ (QUEUE *Q1, QUEUE *Q2){
|
275
|
+
Q1->s = Q1->t = 0;
|
276
|
+
QUEUE_concat_ (Q1, Q2);
|
277
|
+
}
|
278
|
+
void QUEUE_cpy (QUEUE *Q1, QUEUE *Q2){
|
279
|
+
QUEUE_RMALL (*Q1);
|
280
|
+
QUEUE_concat (Q1, Q2);
|
281
|
+
}
|
282
|
+
|
283
|
+
/* compare two queues */
|
284
|
+
int QUEUE_cmp_ (QUEUE *Q1, QUEUE *Q2){
|
285
|
+
QUEUE_INT *x, *y=Q2->v;
|
286
|
+
MQUE_FLOOP (*Q1, x){
|
287
|
+
if ( *x != *y ) return (0);
|
288
|
+
y++;
|
289
|
+
}
|
290
|
+
return (1);
|
291
|
+
}
|
292
|
+
|
293
|
+
/* copy l elements of Q2 starting from s2 to the s1th position of Q1.
|
294
|
+
size of Q1 is not increasing */
|
295
|
+
void QUEUE_subcpy_ (QUEUE *Q1, QUEUE_ID s1, QUEUE *Q2, QUEUE_ID s2, QUEUE_ID l){
|
296
|
+
memcpy ( &(Q1->v[s1]), &(Q2->v[s2]), (l-s2)*sizeof(QUEUE_INT));
|
297
|
+
}
|
298
|
+
void QUEUE_subcpy (QUEUE *Q1, QUEUE_ID s1, QUEUE *Q2, QUEUE_ID s2, QUEUE_ID l){
|
299
|
+
for ( ; s2!=l ; QUEUE_INCREMENT(*Q1,s1),QUEUE_INCREMENT(*Q2,s2) )
|
300
|
+
Q1->v[s1] = Q2->v[s2];
|
301
|
+
Q1->v[s1] = Q2->v[s2];
|
302
|
+
}
|
303
|
+
|
304
|
+
/* duplicate Q2 to Q1. The memory size will be the length of Q2 */
|
305
|
+
QUEUE QUEUE_dup_ (QUEUE *Q){
|
306
|
+
QUEUE QQ;
|
307
|
+
QUEUE_alloc (&QQ, MAX(Q->t+1, Q->end-1));
|
308
|
+
QUEUE_cpy_ (&QQ, Q);
|
309
|
+
return (QQ);
|
310
|
+
}
|
311
|
+
|
312
|
+
/* merge Q1 and Q2 by insert all elements of Q2 to Q1 with deleting duplications. Both Q1 and Q2 have to be sorted in increasing order */
|
313
|
+
void QUEUE_merge_ (QUEUE *Q1, QUEUE *Q2){
|
314
|
+
QUEUE_ID i=Q1->t-1, j=Q2->t-1, t=i+j-Q2->s+1;
|
315
|
+
QUEUE_INT ei, ej;
|
316
|
+
if ( i+1 == Q1->s || j+1 == Q2->s ){
|
317
|
+
QUEUE_concat_ (Q1, Q2);
|
318
|
+
return;
|
319
|
+
}
|
320
|
+
Q1->t = t+1;
|
321
|
+
ei = Q1->v[i];
|
322
|
+
ej = Q2->v[j];
|
323
|
+
while (1){
|
324
|
+
if ( ei > ej ){
|
325
|
+
Q1->v[t] = ei;
|
326
|
+
if ( i == Q1->s ){
|
327
|
+
QUEUE_subcpy_ (Q1, Q1->s, Q2, Q2->s, j);
|
328
|
+
return;
|
329
|
+
}
|
330
|
+
i--;
|
331
|
+
ei = Q1->v[i];
|
332
|
+
} else {
|
333
|
+
Q1->v[t] = ej;
|
334
|
+
if ( j == Q2->s ) return;
|
335
|
+
j--;
|
336
|
+
ej = Q2->v[j];
|
337
|
+
}
|
338
|
+
t--;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
void QUEUE_merge (QUEUE *Q1, QUEUE *Q2){
|
342
|
+
QUEUE_ID i=Q1->t, j=Q2->t;
|
343
|
+
QUEUE_INT ei, ej;
|
344
|
+
QUEUE_ID t = (Q1->t + QUEUE_LENGTH(*Q2)-1) % Q1->end;
|
345
|
+
if ( QUEUE_LENGTH(*Q1) + QUEUE_LENGTH(*Q2) >= Q1->end ){
|
346
|
+
print_err ("QUEUE_merge: overflow Q1->end="QUEUE_INTF", Q1length="QUEUE_INTF", Q2length="QUEUE_INTF"\n", Q1->end, QUEUE_LENGTH(*Q1), QUEUE_LENGTH(*Q2));
|
347
|
+
exit (1);
|
348
|
+
}
|
349
|
+
if ( i == Q1->s || j == Q2->s ){
|
350
|
+
QUEUE_concat (Q1, Q2);
|
351
|
+
return;
|
352
|
+
}
|
353
|
+
|
354
|
+
Q1->t = t;
|
355
|
+
QUEUE_DECREMENT(*Q1,i);
|
356
|
+
QUEUE_DECREMENT(*Q2,j);
|
357
|
+
ei = Q1->v[i];
|
358
|
+
ej = Q2->v[j];
|
359
|
+
while (1){
|
360
|
+
if ( ei > ej ){
|
361
|
+
Q1->v[t] = ei;
|
362
|
+
if ( i == Q1->s ){
|
363
|
+
QUEUE_subcpy (Q1, Q1->s, Q2, Q2->s, (j+Q2->end-Q2->s)%Q2->end);
|
364
|
+
return;
|
365
|
+
}
|
366
|
+
QUEUE_DECREMENT(*Q1,i);
|
367
|
+
ei = Q1->v[i];
|
368
|
+
} else {
|
369
|
+
Q1->v[t] = ej;
|
370
|
+
if ( j == Q2->s ) return;
|
371
|
+
QUEUE_DECREMENT(*Q2,j);
|
372
|
+
ej = Q2->v[j];
|
373
|
+
}
|
374
|
+
QUEUE_DECREMENT(*Q1,t);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
|
378
|
+
/* delete all elements of Q1 included in Q2.
|
379
|
+
both Q1 and Q2 have to be sorted in increasing order */
|
380
|
+
void QUEUE_minus_ (QUEUE *Q1, QUEUE *Q2){
|
381
|
+
QUEUE_ID i=Q1->s, i2 = Q2->s, ii=Q1->s;
|
382
|
+
while ( i != Q1->t && i2 != Q2->t){
|
383
|
+
if (Q1->v[i] > Q2->v[i2] ) i2++;
|
384
|
+
else {
|
385
|
+
if (Q1->v[i] < Q2->v[i2] ){
|
386
|
+
Q1->v[ii] = Q1->v[i];
|
387
|
+
ii++;
|
388
|
+
}
|
389
|
+
i++;
|
390
|
+
}
|
391
|
+
}
|
392
|
+
while ( i != Q1->t ){
|
393
|
+
Q1->v[ii] = Q1->v[i];
|
394
|
+
i++;
|
395
|
+
ii++;
|
396
|
+
}
|
397
|
+
Q1->t = ii;
|
398
|
+
}
|
399
|
+
void QUEUE_minus (QUEUE *Q1, QUEUE *Q2){
|
400
|
+
QUEUE_ID i=Q1->s, i2 = Q2->s, ii=Q1->s;
|
401
|
+
while ( i != Q1->t && i2 != Q2->t ){
|
402
|
+
if ( Q1->v[i] > Q2->v[i2] ) QUEUE_INCREMENT (*Q2, i2);
|
403
|
+
else {
|
404
|
+
if ( Q1->v[i] < Q2->v[i2] ){
|
405
|
+
Q1->v[ii] = Q1->v[i];
|
406
|
+
QUEUE_INCREMENT (*Q1, ii);
|
407
|
+
}
|
408
|
+
QUEUE_INCREMENT (*Q1, i);
|
409
|
+
}
|
410
|
+
}
|
411
|
+
while ( i != Q1->t ){
|
412
|
+
Q1->v[ii] = Q1->v[i];
|
413
|
+
QUEUE_INCREMENT (*Q1, i);
|
414
|
+
QUEUE_INCREMENT (*Q1, ii);
|
415
|
+
}
|
416
|
+
Q1->t = ii;
|
417
|
+
}
|
418
|
+
|
419
|
+
/* Delete all elements of Q1 which are not included in Q2.
|
420
|
+
both Q1 and Q2 have to be sorted in increasing order */
|
421
|
+
QUEUE_ID QUEUE_intsec_ (QUEUE *Q1, QUEUE *Q2){
|
422
|
+
QUEUE_ID i=Q1->s, i2 = Q2->s, c=0;
|
423
|
+
while ( i != Q1->t ){
|
424
|
+
if ( Q1->v[i] > Q2->v[i2] ){
|
425
|
+
if ( ++i2 == Q2->t ) break;
|
426
|
+
} else {
|
427
|
+
if ( Q1->v[i] == Q2->v[i2] ) c++;
|
428
|
+
i++;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
return (c);
|
432
|
+
}
|
433
|
+
void QUEUE_and_ (QUEUE *Q1, QUEUE *Q2){
|
434
|
+
QUEUE_ID i=Q1->s, i2 = Q2->s, ii=Q1->s;
|
435
|
+
while ( i != Q1->t ){
|
436
|
+
if ( Q1->v[i] > Q2->v[i2] ){
|
437
|
+
if ( ++i2 == Q2->t ) break;
|
438
|
+
} else {
|
439
|
+
if ( Q1->v[i] == Q2->v[i2] ) Q1->v[ii++] = Q1->v[i];
|
440
|
+
i++;
|
441
|
+
}
|
442
|
+
}
|
443
|
+
Q1->t = ii;
|
444
|
+
}
|
445
|
+
void QUEUE_and (QUEUE *Q1, QUEUE *Q2){
|
446
|
+
QUEUE_ID i=Q1->s, i2 = Q2->s, ii=Q1->s;
|
447
|
+
while ( i != Q1->t && i2 != Q2->t){
|
448
|
+
if ( Q1->v[i] > Q2->v[i2] ) QUEUE_INCREMENT (*Q2, i2);
|
449
|
+
else {
|
450
|
+
if ( Q1->v[i] == Q2->v[i2] ){
|
451
|
+
Q1->v[ii] = Q1->v[i];
|
452
|
+
QUEUE_INCREMENT (*Q1, ii);
|
453
|
+
}
|
454
|
+
QUEUE_INCREMENT (*Q1, i);
|
455
|
+
}
|
456
|
+
}
|
457
|
+
Q1->t = ii;
|
458
|
+
}
|
459
|
+
|
460
|
+
/* insertion sort */
|
461
|
+
void QUEUE_sort (QUEUE *Q){
|
462
|
+
QUEUE_ID i = Q->s, j, jj;
|
463
|
+
QUEUE_INT e;
|
464
|
+
if ( i== Q->t ) return;
|
465
|
+
QUEUE_INCREMENT(*Q,i);
|
466
|
+
for ( ; i!=Q->t ; QUEUE_INCREMENT(*Q,i) ){
|
467
|
+
e=Q->v[i];
|
468
|
+
j=i;
|
469
|
+
while (1){
|
470
|
+
jj = j;
|
471
|
+
QUEUE_DECREMENT(*Q,j);
|
472
|
+
if ( Q->v[j] <= e ) { Q->v[jj] = e; break; }
|
473
|
+
Q->v[jj] = Q->v[j];
|
474
|
+
if ( j == Q->s) { Q->v[j] = e; break; }
|
475
|
+
}
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
/* print a queue */
|
481
|
+
void QUEUE_print (QUEUE *Q){
|
482
|
+
QUEUE_ID i;
|
483
|
+
for ( i=Q->s ; i!=Q->t ; ){
|
484
|
+
printf (QUEUE_INTF" ", Q->v[i]);
|
485
|
+
QUEUE_INCREMENT(*Q,i);
|
486
|
+
}
|
487
|
+
printf ("\n");
|
488
|
+
}
|
489
|
+
/* permutation version */
|
490
|
+
void QUEUE_perm_print (QUEUE *Q, QUEUE_ID *q){
|
491
|
+
QUEUE_ID i;
|
492
|
+
for ( i=Q->s ; i!=Q->t ; ){
|
493
|
+
printf (QUEUE_INTF" ", q[Q->v[i]]);
|
494
|
+
QUEUE_INCREMENT(*Q,i);
|
495
|
+
}
|
496
|
+
printf ("\n");
|
497
|
+
}
|
498
|
+
void QUEUE_printn (QUEUE *Q){
|
499
|
+
QUEUE_ID i;
|
500
|
+
for ( i=Q->s ; i!=Q->t ; ){
|
501
|
+
printf (QUEUE_INTF" ", Q->v[i]);
|
502
|
+
QUEUE_INCREMENT(*Q,i);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
void QUEUE_perm_printn (QUEUE *Q, QUEUE_ID *q){
|
506
|
+
QUEUE_ID i;
|
507
|
+
for ( i=Q->s ; i!=Q->t ; ){
|
508
|
+
printf (QUEUE_INTF" ",q[Q->v[i]]);
|
509
|
+
QUEUE_INCREMENT(*Q,i);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
void QUEUE_print_ (QUEUE *Q){
|
513
|
+
QUEUE_ID i;
|
514
|
+
printf("s="QUEUE_IDF",t="QUEUE_INTF": ", Q->s, Q->t);
|
515
|
+
for ( i=Q->s ; i!=Q->t ; ){
|
516
|
+
printf (QUEUE_INTF" ",Q->v[i]);
|
517
|
+
QUEUE_INCREMENT(*Q,i);
|
518
|
+
}
|
519
|
+
printf ("\n");
|
520
|
+
}
|
521
|
+
|
522
|
+
void QUEUE_print__ (QUEUE *Q){
|
523
|
+
QUEUE_ID i;
|
524
|
+
printf("s="QUEUE_IDF",t="QUEUE_IDF": ", Q->s, Q->t);
|
525
|
+
for ( i=Q->s ; i!=Q->t ; i++ ) printf (QUEUE_INTF" ",Q->v[i]);
|
526
|
+
printf ("\n");
|
527
|
+
}
|
528
|
+
|
529
|
+
#endif
|
@@ -0,0 +1,177 @@
|
|
1
|
+
/* Library of queue: spped priority implementation
|
2
|
+
12/Apr/2001 by Takeaki Uno e-mail:uno@nii.jp,
|
3
|
+
homepage: http://research.nii.ac.jp/~uno/index.html */
|
4
|
+
/* This program is available for only academic use, basically.
|
5
|
+
Anyone can modify this program, but he/she has to write down
|
6
|
+
the change of the modification on the top of the source code.
|
7
|
+
Neither contact nor appointment to Takeaki Uno is needed.
|
8
|
+
If one wants to re-distribute this code, do not forget to
|
9
|
+
refer the newest code, and show the link to homepage of
|
10
|
+
Takeaki Uno, to notify the news about the codes for the users.
|
11
|
+
For the commercial use, please make a contact to Takeaki Uno. */
|
12
|
+
|
13
|
+
#ifndef _queue_h_
|
14
|
+
#define _queue_h_
|
15
|
+
|
16
|
+
#include"stdlib2.h"
|
17
|
+
|
18
|
+
#ifndef QUEUE_INT
|
19
|
+
#ifdef QUEUE_INT_LONG
|
20
|
+
#define QUEUE_INT LONG // define the type before if change is needed
|
21
|
+
#define QUEUE_INTHUGE LONGHUGE // comment out if QUEUE_INT is "short"
|
22
|
+
#define QUEUE_INTF LONGF
|
23
|
+
#else
|
24
|
+
#define QUEUE_INT int // define the type before if change is needed
|
25
|
+
#define QUEUE_INTHUGE INTHUGE // comment out if QUEUE_INT is "short"
|
26
|
+
#define QUEUE_INTF "%d"
|
27
|
+
#endif
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#ifndef QUEUE_ID
|
31
|
+
#ifdef QUEUE_ID_LONG
|
32
|
+
#define QUEUE_ID LONG // define the type before if change is needed
|
33
|
+
#define QUEUE_IDHUGE LONGHUGE // comment out if QUEUE_INT is "short"
|
34
|
+
#define QUEUE_IDF LONGF
|
35
|
+
#else
|
36
|
+
#define QUEUE_ID int // define the type before if change is needed
|
37
|
+
#define QUEUE_IDHUGE INTHUGE // comment out if QUEUE_INT is "short"
|
38
|
+
#define QUEUE_IDF "%d"
|
39
|
+
#endif
|
40
|
+
#endif
|
41
|
+
#define SWAP_QUEUE_INT(a,b) (common_QUEUE_INT=a,a=b,b=common_QUEUE_INT)
|
42
|
+
#define SWAP_QUEUE_ID(a,b) (common_QUEUE_ID=a,a=b,b=common_QUEUE_ID)
|
43
|
+
|
44
|
+
typedef struct {
|
45
|
+
unsigned char type; // type of the structure
|
46
|
+
QUEUE_INT *v; // pointer to the array
|
47
|
+
QUEUE_ID end; // the length of the array
|
48
|
+
QUEUE_ID t; // end position+1
|
49
|
+
QUEUE_ID s; // start position
|
50
|
+
} QUEUE;
|
51
|
+
|
52
|
+
/* QUEUE stores at most end-1 elements. Overflow occurs after inserting end-1 elements */
|
53
|
+
|
54
|
+
#define QUEUE_INCREMENT(Q,i) ((i)=((i)>=(Q).end-1)?0:(i)+1)
|
55
|
+
#define QUEUE_DECREMENT(Q,i) ((i)=(i)==0?(Q).end-1:(i)-1)
|
56
|
+
#define QUEUE_LENGTH(Q) (((Q).t-(Q).s+(Q).end)%(Q).end)
|
57
|
+
#define QUEUE_LENGTH_(Q) ((Q).t-(Q).s)
|
58
|
+
|
59
|
+
/* macro for loop w.r.t., QUEUE */
|
60
|
+
#define QUEUE_F_LOOP(Q,i) for((i)=(Q).s;(i)!=(Q).t;((i)=((i)>=(Q).end-1)?0:(i)+1))
|
61
|
+
#define QUEUE_F_LOOP_(Q,i) for((i)=(Q).s;(i)<(Q).t;(i)++)
|
62
|
+
#define QUEUE_FE_LOOP(Q,i,x) for((i)=(Q).s,x=(Q).v[i];(i)!=(Q).t;((i)=((i)>=(Q).end-1)?0:(i)+1),x=(Q).v[i])
|
63
|
+
#define QUEUE_FE_LOOP_(Q,i,x) for((i)=(Q).s,x=(Q).v[i];(i)<(Q).t;(i)++,x=(Q).v[i])
|
64
|
+
#define QUEUE_B_LOOP(Q,i) for((i)=(Q).t==0?(Q).end-1:(Q).t-1;(i)!=(Q).s;(i)=(i)==0?(Q).end-1:(i)-1)
|
65
|
+
#define QUEUE_B_LOOP_(Q,i) for((i)=(Q).t-1;(i)>=(Q).s;(i)--)
|
66
|
+
#define QUEUE_BE_LOOP(Q,i,x) for((i)=(Q).t==0?(Q).end-1:(Q).t-1,x=(Q).v[i];(i)!=(Q).s;(i)=(i)==0?(Q).end-1:(i)-1,x=(Q).v[i])
|
67
|
+
#define QUEUE_BE_LOOP_(Q,i,x) for((i)=(Q).t-1;((i)>=(Q).s)?((x=(Q).v[i])||1):0;(i)--)
|
68
|
+
|
69
|
+
#define QUEUE_RMALL(Q) ((Q).t=(Q).s)
|
70
|
+
#define QUEUE_RMALL_(Q) ((Q).t=0)
|
71
|
+
#define QUEUE_HEAD(Q) ((Q).v[(Q).s])
|
72
|
+
#define QUEUE_TAIL_(Q) ((Q).v[(Q).t-1])
|
73
|
+
|
74
|
+
extern QUEUE INIT_QUEUE;
|
75
|
+
extern QUEUE_INT common_QUEUE_INT, *common_QUEUE_INTp;
|
76
|
+
QSORT_TYPE_HEADER(QUEUE_INT, QUEUE_INT)
|
77
|
+
QSORT_TYPE_HEADER(QUEUE_ID, QUEUE_ID)
|
78
|
+
|
79
|
+
|
80
|
+
/* initialization, not fill the memory by 0 */
|
81
|
+
void QUEUE_alloc (QUEUE *Q, QUEUE_ID siz);
|
82
|
+
|
83
|
+
/* termination processing */
|
84
|
+
void QUEUE_end (QUEUE *Q);
|
85
|
+
|
86
|
+
/* delivery: transpose that matrinx (transaction database) Q. Each row of the
|
87
|
+
transposed matrix is called occurrence.
|
88
|
+
|
89
|
+
variables to be set.
|
90
|
+
OQ:array for occurrences, c: for counting frequency, jump: list of items with non-empty OQ
|
91
|
+
if c!=NULL, count the frequency and set to c, and set occurrences to OQ, otherwise.
|
92
|
+
if jump==NULL, then the list of non-empty item will not be generated
|
93
|
+
Q:matrix, of an array of QUEUE, occ: list of rows of Q to be scaned, t; maximum ID of the
|
94
|
+
row to be scaned; if occ==NULL, occ will be ignored, otherwise t will be ignored.
|
95
|
+
M: end mark of each QUEUE. */
|
96
|
+
void QUEUE_delivery(QUEUE *OQ, VEC_ID *c, QUEUE *jump, QUEUE *Q, QUEUE *occ, VEC_ID t, QUEUE_INT M);
|
97
|
+
/* sort a QUEUE with WEIGHT, with already allocated memory (size have to no less than the size of QUEUE) */
|
98
|
+
void QUEUE_perm_WEIGHT (QUEUE *Q, WEIGHT *w, PERM *invperm, int flag);
|
99
|
+
|
100
|
+
/* remove (or unify) the consecutive same ID's in a QUEUE (duplication delete, if sorted) */
|
101
|
+
void QUEUE_rm_dup_WEIGHT (QUEUE *Q, WEIGHT *w);
|
102
|
+
|
103
|
+
/***********************************************************************/
|
104
|
+
/* duplicate occ's in jump, ( copy occ's to allocated QUEUE array) */
|
105
|
+
/* Q[i].end := original item, clear each original occ */
|
106
|
+
/* buffer size is multiplied by u */
|
107
|
+
/*******************************************************/
|
108
|
+
|
109
|
+
|
110
|
+
void QUEUE_occ_dup (QUEUE *jump, QUEUE **QQ, QUEUE *Q, WEIGHT **ww, WEIGHT *w, WEIGHT **ppw, WEIGHT *pw, int u);
|
111
|
+
|
112
|
+
/* return the position of the first element having value e. return -1 if no such element exists */
|
113
|
+
LONG QUEUE_ele (QUEUE *Q, QUEUE_INT e);
|
114
|
+
|
115
|
+
/* insert an element to the tail/head */
|
116
|
+
void QUEUE_ins_ (QUEUE *Q, QUEUE_INT e);
|
117
|
+
void QUEUE_ins (QUEUE *Q, QUEUE_INT e);
|
118
|
+
void QUEUE_ins_head_ (QUEUE *Q, QUEUE_INT e);
|
119
|
+
void QUEUE_ins_head (QUEUE *Q, QUEUE_INT e);
|
120
|
+
|
121
|
+
/* extract an element from the head/tail, without checking the underflow */
|
122
|
+
QUEUE_INT QUEUE_ext_ (QUEUE *Q);
|
123
|
+
QUEUE_INT QUEUE_ext (QUEUE *Q);
|
124
|
+
QUEUE_INT QUEUE_ext_tail_ (QUEUE *Q);
|
125
|
+
QUEUE_INT QUEUE_ext_tail (QUEUE *Q);
|
126
|
+
|
127
|
+
/* remove the j-th element and replace it by the tail/head or shift */
|
128
|
+
void QUEUE_rm_ (QUEUE *Q, QUEUE_ID j);
|
129
|
+
void QUEUE_rm (QUEUE *Q, QUEUE_ID j);
|
130
|
+
void QUEUE_rm_head_ (QUEUE *Q, QUEUE_ID j);
|
131
|
+
void QUEUE_rm_head (QUEUE *Q, QUEUE_ID j);
|
132
|
+
int QUEUE_rm_ele_ (QUEUE *Q, QUEUE_INT e);
|
133
|
+
|
134
|
+
/* Append Q2 to the tail of Q1. Q2 will (not) be deleted */
|
135
|
+
void QUEUE_append_ (QUEUE *Q1, QUEUE *Q2);
|
136
|
+
void QUEUE_append (QUEUE *Q1, QUEUE *Q2);
|
137
|
+
void QUEUE_concat_ (QUEUE *Q1, QUEUE *Q2);
|
138
|
+
void QUEUE_concat (QUEUE *Q1, QUEUE *Q2);
|
139
|
+
|
140
|
+
/* Append from j to jj th elements to the tail of Q1. Q2 will not be deleted */
|
141
|
+
void QUEUE_subconcat_ (QUEUE *Q1, QUEUE *Q2, QUEUE_ID j, QUEUE_ID jj);
|
142
|
+
void QUEUE_subconcat (QUEUE *Q1, QUEUE *Q2, QUEUE_ID j, QUEUE_ID jj);
|
143
|
+
|
144
|
+
/* initialize Q1 by length of Q2, and copy Q2 to Q1 */
|
145
|
+
void QUEUE_store_ (QUEUE *Q1, QUEUE *Q2);
|
146
|
+
void QUEUE_store (QUEUE *Q1, QUEUE *Q2);
|
147
|
+
/* copy Q2 to Q1 and delete Q2 */
|
148
|
+
void QUEUE_restore_ (QUEUE *Q1, QUEUE *Q2);
|
149
|
+
void QUEUE_restore (QUEUE *Q1, QUEUE *Q2);
|
150
|
+
|
151
|
+
/* copy Q2 to Q1 */
|
152
|
+
void QUEUE_cpy_ (QUEUE *Q1, QUEUE *Q2);
|
153
|
+
void QUEUE_cpy (QUEUE *Q1, QUEUE *Q2);
|
154
|
+
QUEUE QUEUE_dup_ (QUEUE *Q);
|
155
|
+
/* copy l elements of Q2 starting from s2 to the s1th position of Q1.
|
156
|
+
size of Q1 is not increasing */
|
157
|
+
void QUEUE_subcpy_ (QUEUE *Q1, QUEUE_ID s1, QUEUE *Q2, QUEUE_ID s2, QUEUE_ID l);
|
158
|
+
void QUEUE_subcpy (QUEUE *Q1, QUEUE_ID s1, QUEUE *Q2, QUEUE_ID s2, QUEUE_ID l);
|
159
|
+
|
160
|
+
/* merge/minum/intersection of Q1 and Q2, and set Q1 to it.
|
161
|
+
Both Q1 and Q2 have to be sorted in increasing order */
|
162
|
+
void QUEUE_merge_ (QUEUE *Q1, QUEUE *Q2);
|
163
|
+
void QUEUE_merge (QUEUE *Q1, QUEUE *Q2);
|
164
|
+
void QUEUE_minus_ (QUEUE *Q1, QUEUE *Q2);
|
165
|
+
void QUEUE_minus (QUEUE *Q1, QUEUE *Q2);
|
166
|
+
void QUEUE_and_ (QUEUE *Q1, QUEUE *Q2);
|
167
|
+
void QUEUE_and (QUEUE *Q1, QUEUE *Q2);
|
168
|
+
|
169
|
+
/* insertion sort */
|
170
|
+
void QUEUE_sort (QUEUE *Q);
|
171
|
+
|
172
|
+
/* print */
|
173
|
+
void QUEUE_print (QUEUE *Q);
|
174
|
+
void QUEUE_print_ (QUEUE *Q);
|
175
|
+
|
176
|
+
|
177
|
+
#endif
|