1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
|
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QFRAGMENTMAP_P_H
#define QFRAGMENTMAP_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "QtCore/qglobal.h"
#include <stdlib.h>
#include <private/qtools_p.h>
QT_BEGIN_NAMESPACE
template <int N = 1>
class QFragment
{
public:
quint32 parent;
quint32 left;
quint32 right;
quint32 color;
quint32 size_left_array[N];
quint32 size_array[N];
enum {size_array_max = N };
};
template <class Fragment>
class QFragmentMapData
{
enum Color { Red, Black };
public:
QFragmentMapData();
~QFragmentMapData();
void init();
class Header
{
public:
quint32 root; // this relies on being at the same position as parent in the fragment struct
quint32 tag;
quint32 freelist;
quint32 node_count;
quint32 allocated;
};
enum {fragmentSize = sizeof(Fragment) };
int length(uint field = 0) const;
inline Fragment *fragment(uint index) {
return (fragments + index);
}
inline const Fragment *fragment(uint index) const {
return (fragments + index);
}
inline Fragment &F(uint index) { return fragments[index] ; }
inline const Fragment &F(uint index) const { return fragments[index] ; }
inline bool isRoot(uint index) const {
return !fragment(index)->parent;
}
inline uint position(uint node, uint field = 0) const {
Q_ASSERT(field < Fragment::size_array_max);
const Fragment *f = fragment(node);
uint offset = f->size_left_array[field];
while (f->parent) {
uint p = f->parent;
f = fragment(p);
if (f->right == node)
offset += f->size_left_array[field] + f->size_array[field];
node = p;
}
return offset;
}
inline uint sizeRight(uint node, uint field = 0) const {
Q_ASSERT(field < Fragment::size_array_max);
uint sr = 0;
const Fragment *f = fragment(node);
node = f->right;
while (node) {
f = fragment(node);
sr += f->size_left_array[field] + f->size_array[field];
node = f->right;
}
return sr;
}
inline uint sizeLeft(uint node, uint field = 0) const {
Q_ASSERT(field < Fragment::size_array_max);
return fragment(node)->size_left_array[field];
}
inline uint size(uint node, uint field = 0) const {
Q_ASSERT(field < Fragment::size_array_max);
return fragment(node)->size_array[field];
}
inline void setSize(uint node, int new_size, uint field = 0) {
Q_ASSERT(field < Fragment::size_array_max);
Fragment *f = fragment(node);
int diff = new_size - f->size_array[field];
f->size_array[field] = new_size;
while (f->parent) {
uint p = f->parent;
f = fragment(p);
if (f->left == node)
f->size_left_array[field] += diff;
node = p;
}
}
uint findNode(int k, uint field = 0) const;
uint insert_single(int key, uint length);
uint erase_single(uint f);
uint minimum(uint n) const {
while (n && fragment(n)->left)
n = fragment(n)->left;
return n;
}
uint maximum(uint n) const {
while (n && fragment(n)->right)
n = fragment(n)->right;
return n;
}
uint next(uint n) const;
uint previous(uint n) const;
inline uint root() const {
Q_ASSERT(!head->root || !fragment(head->root)->parent);
return head->root;
}
inline void setRoot(uint new_root) {
Q_ASSERT(!head->root || !fragment(new_root)->parent);
head->root = new_root;
}
union {
Header *head;
Fragment *fragments;
};
private:
void rotateLeft(uint x);
void rotateRight(uint x);
void rebalance(uint x);
void removeAndRebalance(uint z);
uint createFragment();
void freeFragment(uint f);
};
template <class Fragment>
QFragmentMapData<Fragment>::QFragmentMapData()
{
init();
}
template <class Fragment>
void QFragmentMapData<Fragment>::init()
{
fragments = (Fragment *)malloc(64*fragmentSize);
head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p');
head->root = 0;
head->freelist = 1;
head->node_count = 0;
head->allocated = 64;
// mark all items to the right as unused
F(head->freelist).right = 0;
}
template <class Fragment>
QFragmentMapData<Fragment>::~QFragmentMapData()
{
free(head);
}
template <class Fragment>
uint QFragmentMapData<Fragment>::createFragment()
{
Q_ASSERT(head->freelist <= head->allocated);
uint freePos = head->freelist;
if (freePos == head->allocated) {
// need to create some free space
uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
Q_ASSERT(needed/fragmentSize > head->allocated);
fragments = (Fragment *)realloc(fragments, needed);
head->allocated = needed/fragmentSize;
F(freePos).right = 0;
}
uint nextPos = F(freePos).right;
if (!nextPos) {
nextPos = freePos+1;
if (nextPos < head->allocated)
F(nextPos).right = 0;
}
head->freelist = nextPos;
++head->node_count;
return freePos;
}
template <class Fragment>
void QFragmentMapData<Fragment>::freeFragment(uint i)
{
F(i).right = head->freelist;
head->freelist = i;
--head->node_count;
}
template <class Fragment>
uint QFragmentMapData<Fragment>::next(uint n) const {
Q_ASSERT(n);
if (F(n).right) {
n = F(n).right;
while (F(n).left)
n = F(n).left;
} else {
uint y = F(n).parent;
while (F(n).parent && n == F(y).right) {
n = y;
y = F(y).parent;
}
n = y;
}
return n;
}
template <class Fragment>
uint QFragmentMapData<Fragment>::previous(uint n) const {
if (!n)
return maximum(root());
if (F(n).left) {
n = F(n).left;
while (F(n).right)
n = F(n).right;
} else {
uint y = F(n).parent;
while (F(n).parent && n == F(y).left) {
n = y;
y = F(y).parent;
}
n = y;
}
return n;
}
/*
x y
\ / \
y --> x b
/ \ \
a b a
*/
template <class Fragment>
void QFragmentMapData<Fragment>::rotateLeft(uint x)
{
uint p = F(x).parent;
uint y = F(x).right;
if (y) {
F(x).right = F(y).left;
if (F(y).left)
F(F(y).left).parent = x;
F(y).left = x;
F(y).parent = p;
} else {
F(x).right = 0;
}
if (!p) {
Q_ASSERT(head->root == x);
head->root = y;
}
else if (x == F(p).left)
F(p).left = y;
else
F(p).right = y;
F(x).parent = y;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(y).size_left_array[field] += F(x).size_left_array[field] + F(x).size_array[field];
}
/*
x y
/ / \
y --> a x
/ \ /
a b b
*/
template <class Fragment>
void QFragmentMapData<Fragment>::rotateRight(uint x)
{
uint y = F(x).left;
uint p = F(x).parent;
if (y) {
F(x).left = F(y).right;
if (F(y).right)
F(F(y).right).parent = x;
F(y).right = x;
F(y).parent = p;
} else {
F(x).left = 0;
}
if (!p) {
Q_ASSERT(head->root == x);
head->root = y;
}
else if (x == F(p).right)
F(p).right = y;
else
F(p).left = y;
F(x).parent = y;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(x).size_left_array[field] -= F(y).size_left_array[field] + F(y).size_array[field];
}
template <class Fragment>
void QFragmentMapData<Fragment>::rebalance(uint x)
{
F(x).color = Red;
while (F(x).parent && F(F(x).parent).color == Red) {
uint p = F(x).parent;
uint pp = F(p).parent;
Q_ASSERT(pp);
if (p == F(pp).left) {
uint y = F(pp).right;
if (y && F(y).color == Red) {
F(p).color = Black;
F(y).color = Black;
F(pp).color = Red;
x = pp;
} else {
if (x == F(p).right) {
x = p;
rotateLeft(x);
p = F(x).parent;
pp = F(p).parent;
}
F(p).color = Black;
if (pp) {
F(pp).color = Red;
rotateRight(pp);
}
}
} else {
uint y = F(pp).left;
if (y && F(y).color == Red) {
F(p).color = Black;
F(y).color = Black;
F(pp).color = Red;
x = pp;
} else {
if (x == F(p).left) {
x = p;
rotateRight(x);
p = F(x).parent;
pp = F(p).parent;
}
F(p).color = Black;
if (pp) {
F(pp).color = Red;
rotateLeft(pp);
}
}
}
}
F(root()).color = Black;
}
template <class Fragment>
uint QFragmentMapData<Fragment>::erase_single(uint z)
{
uint w = previous(z);
uint y = z;
uint x;
uint p;
if (!F(y).left) {
x = F(y).right;
} else if (!F(y).right) {
x = F(y).left;
} else {
y = F(y).right;
while (F(y).left)
y = F(y).left;
x = F(y).right;
}
if (y != z) {
F(F(z).left).parent = y;
F(y).left = F(z).left;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(y).size_left_array[field] = F(z).size_left_array[field];
if (y != F(z).right) {
/*
z y
/ \ / \
a b a b
/ /
... --> ...
/ /
y x
/ \
0 x
*/
p = F(y).parent;
if (x)
F(x).parent = p;
F(p).left = x;
F(y).right = F(z).right;
F(F(z).right).parent = y;
uint n = p;
while (n != y) {
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(n).size_left_array[field] -= F(y).size_array[field];
n = F(n).parent;
}
} else {
/*
z y
/ \ / \
a y --> a x
/ \
0 x
*/
p = y;
}
uint zp = F(z).parent;
if (!zp) {
Q_ASSERT(head->root == z);
head->root = y;
} else if (F(zp).left == z) {
F(zp).left = y;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(zp).size_left_array[field] -= F(z).size_array[field];
} else {
F(zp).right = y;
}
F(y).parent = zp;
// Swap the colors
uint c = F(y).color;
F(y).color = F(z).color;
F(z).color = c;
y = z;
} else {
/*
p p p p
/ / \ \
z --> x z --> x
| |
x x
*/
p = F(z).parent;
if (x)
F(x).parent = p;
if (!p) {
Q_ASSERT(head->root == z);
head->root = x;
} else if (F(p).left == z) {
F(p).left = x;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(p).size_left_array[field] -= F(z).size_array[field];
} else {
F(p).right = x;
}
}
uint n = z;
while (F(n).parent) {
uint p = F(n).parent;
if (F(p).left == n) {
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(p).size_left_array[field] -= F(z).size_array[field];
}
n = p;
}
freeFragment(z);
if (F(y).color != Red) {
while (F(x).parent && (x == 0 || F(x).color == Black)) {
if (x == F(p).left) {
uint w = F(p).right;
if (F(w).color == Red) {
F(w).color = Black;
F(p).color = Red;
rotateLeft(p);
w = F(p).right;
}
if ((F(w).left == 0 || F(F(w).left).color == Black) &&
(F(w).right == 0 || F(F(w).right).color == Black)) {
F(w).color = Red;
x = p;
p = F(x).parent;
} else {
if (F(w).right == 0 || F(F(w).right).color == Black) {
if (F(w).left)
F(F(w).left).color = Black;
F(w).color = Red;
rotateRight(F(p).right);
w = F(p).right;
}
F(w).color = F(p).color;
F(p).color = Black;
if (F(w).right)
F(F(w).right).color = Black;
rotateLeft(p);
break;
}
} else {
uint w = F(p).left;
if (F(w).color == Red) {
F(w).color = Black;
F(p).color = Red;
rotateRight(p);
w = F(p).left;
}
if ((F(w).right == 0 || F(F(w).right).color == Black) &&
(F(w).left == 0 || F(F(w).left).color == Black)) {
F(w).color = Red;
x = p;
p = F(x).parent;
} else {
if (F(w).left == 0 || F(F(w).left).color == Black) {
if (F(w).right)
F(F(w).right).color = Black;
F(w).color = Red;
rotateLeft(F(p).left);
w = F(p).left;
}
F(w).color = F(p).color;
F(p).color = Black;
if (F(w).left)
F(F(w).left).color = Black;
rotateRight(p);
break;
}
}
}
if (x)
F(x).color = Black;
}
return w;
}
template <class Fragment>
uint QFragmentMapData<Fragment>::findNode(int k, uint field) const
{
Q_ASSERT(field < Fragment::size_array_max);
uint x = root();
uint s = k;
while (x) {
if (sizeLeft(x, field) <= s) {
if (s < sizeLeft(x, field) + size(x, field))
return x;
s -= sizeLeft(x, field) + size(x, field);
x = F(x).right;
} else {
x = F(x).left;
}
}
return 0;
}
template <class Fragment>
uint QFragmentMapData<Fragment>::insert_single(int key, uint length)
{
Q_ASSERT(!findNode(key) || (int)this->position(findNode(key)) == key);
uint z = createFragment();
F(z).left = 0;
F(z).right = 0;
F(z).size_array[0] = length;
for (uint field = 1; field < Fragment::size_array_max; ++field)
F(z).size_array[field] = 1;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(z).size_left_array[field] = 0;
uint y = 0;
uint x = root();
Q_ASSERT(!x || F(x).parent == 0);
uint s = key;
bool right = false;
while (x) {
y = x;
if (s <= F(x).size_left_array[0]) {
x = F(x).left;
right = false;
} else {
s -= F(x).size_left_array[0] + F(x).size_array[0];
x = F(x).right;
right = true;
}
}
F(z).parent = y;
if (!y) {
head->root = z;
} else if (!right) {
F(y).left = z;
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(y).size_left_array[field] = F(z).size_array[field];
} else {
F(y).right = z;
}
while (y && F(y).parent) {
uint p = F(y).parent;
if (F(p).left == y) {
for (uint field = 0; field < Fragment::size_array_max; ++field)
F(p).size_left_array[field] += F(z).size_array[field];
}
y = p;
}
rebalance(z);
return z;
}
template <class Fragment>
int QFragmentMapData<Fragment>::length(uint field) const {
uint root = this->root();
return root ? sizeLeft(root, field) + size(root, field) + sizeRight(root, field) : 0;
}
template <class Fragment> // NOTE: must inherit QFragment
class QFragmentMap
{
public:
class Iterator
{
public:
QFragmentMap *pt;
quint32 n;
Iterator() : pt(0), n(0) {}
Iterator(QFragmentMap *p, int node) : pt(p), n(node) {}
Iterator(const Iterator& it) : pt(it.pt), n(it.n) {}
inline bool atEnd() const { return !n; }
bool operator==(const Iterator& it) const { return pt == it.pt && n == it.n; }
bool operator!=(const Iterator& it) const { return pt != it.pt || n != it.n; }
bool operator<(const Iterator &it) const { return position() < it.position(); }
Fragment *operator*() { Q_ASSERT(!atEnd()); return pt->fragment(n); }
const Fragment *operator*() const { Q_ASSERT(!atEnd()); return pt->fragment(n); }
Fragment *operator->() { Q_ASSERT(!atEnd()); return pt->fragment(n); }
const Fragment *operator->() const { Q_ASSERT(!atEnd()); return pt->fragment(n); }
int position() const { Q_ASSERT(!atEnd()); return pt->data.position(n); }
const Fragment *value() const { Q_ASSERT(!atEnd()); return pt->fragment(n); }
Fragment *value() { Q_ASSERT(!atEnd()); return pt->fragment(n); }
Iterator& operator++() {
n = pt->data.next(n);
return *this;
}
Iterator& operator--() {
n = pt->data.previous(n);
return *this;
}
};
class ConstIterator
{
public:
const QFragmentMap *pt;
quint32 n;
/**
* Functions
*/
ConstIterator() : pt(0), n(0) {}
ConstIterator(const QFragmentMap *p, int node) : pt(p), n(node) {}
ConstIterator(const ConstIterator& it) : pt(it.pt), n(it.n) {}
ConstIterator(const Iterator& it) : pt(it.pt), n(it.n) {}
inline bool atEnd() const { return !n; }
bool operator==(const ConstIterator& it) const { return pt == it.pt && n == it.n; }
bool operator!=(const ConstIterator& it) const { return pt != it.pt || n != it.n; }
bool operator<(const ConstIterator &it) const { return position() < it.position(); }
const Fragment *operator*() const { Q_ASSERT(!atEnd()); return pt->fragment(n); }
const Fragment *operator->() const { Q_ASSERT(!atEnd()); return pt->fragment(n); }
int position() const { Q_ASSERT(!atEnd()); return pt->data.position(n); }
int size() const { Q_ASSERT(!atEnd()); return pt->data.size(n); }
const Fragment *value() const { Q_ASSERT(!atEnd()); return pt->fragment(n); }
ConstIterator& operator++() {
n = pt->data.next(n);
return *this;
}
ConstIterator& operator--() {
n = pt->data.previous(n);
return *this;
}
};
QFragmentMap() {}
~QFragmentMap()
{
for (Iterator it = begin(); !it.atEnd(); ++it)
it.value()->free();
}
inline void clear() {
for (Iterator it = begin(); !it.atEnd(); ++it)
it.value()->free();
::free(data.head);
data.init();
}
inline Iterator begin() { return Iterator(this, data.minimum(data.root())); }
inline Iterator end() { return Iterator(this, 0); }
inline ConstIterator begin() const { return ConstIterator(this, data.minimum(data.root())); }
inline ConstIterator end() const { return ConstIterator(this, 0); }
inline ConstIterator last() const { return ConstIterator(this, data.maximum(data.root())); }
inline bool isEmpty() const { return data.head->node_count == 0; }
inline int numNodes() const { return data.head->node_count; }
int length(uint field = 0) const { return data.length(field); }
Iterator find(int k, uint field = 0) { return Iterator(this, data.findNode(k, field)); }
ConstIterator find(int k, uint field = 0) const { return ConstIterator(this, data.findNode(k, field)); }
uint findNode(int k, uint field = 0) const { return data.findNode(k, field); }
uint insert_single(int key, uint length)
{
uint f = data.insert_single(key, length);
if (f != 0) {
Fragment *frag = fragment(f);
Q_ASSERT(frag);
frag->initialize();
}
return f;
}
uint erase_single(uint f)
{
if (f != 0) {
Fragment *frag = fragment(f);
Q_ASSERT(frag);
frag->free();
}
return data.erase_single(f);
}
inline Fragment *fragment(uint index) {
Q_ASSERT(index != 0);
return data.fragment(index);
}
inline const Fragment *fragment(uint index) const {
Q_ASSERT(index != 0);
return data.fragment(index);
}
inline uint position(uint node, uint field = 0) const { return data.position(node, field); }
inline uint next(uint n) const { return data.next(n); }
inline uint previous(uint n) const { return data.previous(n); }
inline uint size(uint node, uint field = 0) const { return data.size(node, field); }
inline void setSize(uint node, int new_size, uint field = 0)
{ data.setSize(node, new_size, field);
if (node != 0 && field == 0) {
Fragment *frag = fragment(node);
Q_ASSERT(frag);
frag->invalidate();
}
}
inline int firstNode() const { return data.minimum(data.root()); }
private:
friend class Iterator;
friend class ConstIterator;
QFragmentMapData<Fragment> data;
QFragmentMap(const QFragmentMap& m);
QFragmentMap& operator= (const QFragmentMap& m);
};
QT_END_NAMESPACE
#endif // QFRAGMENTMAP_P_H
|