gravatar
deba@inf.elte.hu
deba@inf.elte.hu
New queue implementation for HaoOrlin class (#58)
0 1 0
default
1 file changed with 31 insertions and 50 deletions:
↑ Collapse diff ↑
Show white space 2 line context
... ...
@@ -227,3 +227,5 @@
227 227

	
228
      int bucket_num = 1;
228
      int bucket_num = 0;
229
      std::vector<Node> queue(_node_num);
230
      int qfirst = 0, qlast = 0, qsep = 0;
229 231

	
... ...
@@ -233,3 +235,2 @@
233 235
        reached.set(_source, true);
234

	
235 236
        bool first_set = true;
... ...
@@ -239,17 +240,9 @@
239 240
          _sets.push_front(std::list<int>());
240
          _sets.front().push_front(bucket_num);
241
          _dormant[bucket_num] = !first_set;
242 241

	
243
          _bucket->set(t, bucket_num);
244
          _first[bucket_num] = _last[bucket_num] = t;
245
          _next->set(t, INVALID);
246
          _prev->set(t, INVALID);
247

	
248
          ++bucket_num;
249

	
250
          std::vector<Node> queue;
251
          queue.push_back(t);
242
          queue[qlast++] = t;
252 243
          reached.set(t, true);
253 244

	
254
          while (!queue.empty()) {
245
          while (qfirst != qlast) {
246
            if (qsep == qfirst) {
247
              ++bucket_num;
255 248
            _sets.front().push_front(bucket_num);
... ...
@@ -257,6 +250,8 @@
257 250
            _first[bucket_num] = _last[bucket_num] = INVALID;
251
              qsep = qlast;
252
            }
258 253

	
259
            std::vector<Node> nqueue;
260
            for (int i = 0; i < int(queue.size()); ++i) {
261
              Node n = queue[i];
254
            Node n = queue[qfirst++];
255
            addItem(n, bucket_num);
256

	
262 257
              for (InArcIt a(_graph, n); a != INVALID; ++a) {
... ...
@@ -265,4 +260,3 @@
265 260
                  reached.set(u, true);
266
                  addItem(u, bucket_num);
267
                  nqueue.push_back(u);
261
                queue[qlast++] = u;
268 262
                }
... ...
@@ -270,7 +264,2 @@
270 264
            }
271
            queue.swap(nqueue);
272
            ++bucket_num;
273
          }
274
          _sets.front().pop_front();
275
          --bucket_num;
276 265
          first_set = false;
... ...
@@ -278,2 +267,3 @@
278 267

	
268
        ++bucket_num;
279 269
        _bucket->set(_source, 0);
... ...
@@ -536,3 +526,5 @@
536 526

	
537
      int bucket_num = 1;
527
      int bucket_num = 0;
528
      std::vector<Node> queue(_node_num);
529
      int qfirst = 0, qlast = 0, qsep = 0;
538 530

	
... ...
@@ -548,17 +540,9 @@
548 540
          _sets.push_front(std::list<int>());
549
          _sets.front().push_front(bucket_num);
550
          _dormant[bucket_num] = !first_set;
551 541

	
552
          _bucket->set(t, bucket_num);
553
          _first[bucket_num] = _last[bucket_num] = t;
554
          _next->set(t, INVALID);
555
          _prev->set(t, INVALID);
556

	
557
          ++bucket_num;
558

	
559
          std::vector<Node> queue;
560
          queue.push_back(t);
542
          queue[qlast++] = t;
561 543
          reached.set(t, true);
562 544

	
563
          while (!queue.empty()) {
545
          while (qfirst != qlast) {
546
            if (qsep == qfirst) {
547
              ++bucket_num;
564 548
            _sets.front().push_front(bucket_num);
... ...
@@ -566,6 +550,8 @@
566 550
            _first[bucket_num] = _last[bucket_num] = INVALID;
551
              qsep = qlast;
552
            }
567 553

	
568
            std::vector<Node> nqueue;
569
            for (int i = 0; i < int(queue.size()); ++i) {
570
              Node n = queue[i];
554
            Node n = queue[qfirst++];
555
            addItem(n, bucket_num);
556

	
571 557
              for (OutArcIt a(_graph, n); a != INVALID; ++a) {
... ...
@@ -574,4 +560,3 @@
574 560
                  reached.set(u, true);
575
                  addItem(u, bucket_num);
576
                  nqueue.push_back(u);
561
                queue[qlast++] = u;
577 562
                }
... ...
@@ -579,7 +564,2 @@
579 564
            }
580
            queue.swap(nqueue);
581
            ++bucket_num;
582
          }
583
          _sets.front().pop_front();
584
          --bucket_num;
585 565
          first_set = false;
... ...
@@ -587,2 +567,3 @@
587 567

	
568
        ++bucket_num;
588 569
        _bucket->set(_source, 0);
... ...
@@ -866,6 +847,6 @@
866 847

	
867
      _first.resize(_node_num + 1);
868
      _last.resize(_node_num + 1);
848
      _first.resize(_node_num);
849
      _last.resize(_node_num);
869 850

	
870
      _dormant.resize(_node_num + 1);
851
      _dormant.resize(_node_num);
871 852

	
0 comments (0 inline)