4#ifndef QFRAGMENTMAP_P_H
5#define QFRAGMENTMAP_P_H
18#include <QtGui/private/qtguiglobal_p.h>
20#include <private/qtools_p.h>
38template <
class Fragment>
41 enum Color { Red, Black };
81 Q_ASSERT(field < Fragment::size_array_max);
88 offset +=
f->size_left_array[field] +
f->size_array[field];
94 Q_ASSERT(field < Fragment::size_array_max);
100 sr +=
f->size_left_array[field] +
f->size_array[field];
106 Q_ASSERT(field < Fragment::size_array_max);
107 return fragment(node)->size_left_array[field];
112 Q_ASSERT(field < Fragment::size_array_max);
113 return fragment(node)->size_array[field];
117 Q_ASSERT(field < Fragment::size_array_max);
119 int diff = new_size -
f->size_array[field];
120 f->size_array[field] = new_size;
125 f->size_left_array[field] += diff;
171 void rotateLeft(
uint x);
172 void rotateRight(
uint x);
173 void rebalance(
uint x);
174 void removeAndRebalance(
uint z);
176 uint createFragment();
177 void freeFragment(
uint f);
181template <
class Fragment>
188template <
class Fragment>
195 fragments = newFragments;
196 head->allocated = 64;
203 head->node_count = 0;
205 F(head->freelist).right = 0;
208template <
class Fragment>
214template <
class Fragment>
217 Q_ASSERT(head->freelist <= head->allocated);
219 uint freePos = head->freelist;
220 if (freePos == head->allocated) {
225 fragments = newFragments;
226 head->allocated =
quint32(blockInfo.elementCount);
227 F(freePos).right = 0;
230 uint nextPos =
F(freePos).right;
233 if (nextPos < head->allocated)
234 F(nextPos).right = 0;
237 head->freelist = nextPos;
244template <
class Fragment>
247 F(
i).right = head->freelist;
254template <
class Fragment>
272template <
class Fragment>
275 return maximum(root());
300template <
class Fragment>
308 F(
x).right = F(
y).left;
325 for (
uint field = 0; field < Fragment::size_array_max; ++field)
326 F(
y).size_left_array[field] +=
F(
x).size_left_array[field] +
F(
x).size_array[field];
337template <
class Fragment>
344 F(
x).left =
F(
y).right;
361 for (
uint field = 0; field < Fragment::size_array_max; ++field)
362 F(
x).size_left_array[field] -=
F(
y).size_left_array[field] +
F(
y).size_array[field];
366template <
class Fragment>
421template <
class Fragment>
442 F(
y).left = F(
z).left;
443 for (
uint field = 0; field < Fragment::size_array_max; ++field)
444 F(
y).size_left_array[field] = F(
z).size_left_array[field];
461 F(
y).right = F(
z).right;
465 for (
uint field = 0; field < Fragment::size_array_max; ++field)
466 F(
n).size_left_array[field] -= F(
y).size_array[field];
479 uint zp = F(
z).parent;
483 }
else if (F(zp).
left ==
z) {
485 for (
uint field = 0; field < Fragment::size_array_max; ++field)
486 F(zp).size_left_array[field] -= F(
z).size_array[field];
493 F(
y).color = F(
z).color;
510 }
else if (F(
p).
left ==
z) {
512 for (
uint field = 0; field < Fragment::size_array_max; ++field)
513 F(
p).size_left_array[field] -= F(
z).size_array[field];
522 for (
uint field = 0; field < Fragment::size_array_max; ++field)
523 F(
p).size_left_array[field] -= F(
z).size_array[field];
549 F(F(
w).
left).color = Black;
554 F(
w).color = F(
p).color;
557 F(F(
w).
right).color = Black;
577 F(F(
w).
right).color = Black;
579 rotateLeft(F(
p).
left);
582 F(
w).color = F(
p).color;
585 F(F(
w).
left).color = Black;
598template <
class Fragment>
601 Q_ASSERT(field < Fragment::size_array_max);
606 if (sizeLeft(
x, field) <=
s) {
607 if (
s < sizeLeft(
x, field) +
size(
x, field))
609 s -= sizeLeft(
x, field) +
size(
x, field);
618template <
class Fragment>
623 uint z = createFragment();
628 for (
uint field = 1; field < Fragment::size_array_max; ++field)
629 F(
z).size_array[field] = 1;
630 for (
uint field = 0; field < Fragment::size_array_max; ++field)
631 F(
z).size_left_array[field] = 0;
642 if (
s <= F(
x).size_left_array[0]) {
646 s -= F(
x).size_left_array[0] + F(
x).size_array[0];
657 for (
uint field = 0; field < Fragment::size_array_max; ++field)
658 F(
y).size_left_array[field] = F(
z).size_array[field];
665 for (
uint field = 0; field < Fragment::size_array_max; ++field)
666 F(
p).size_left_array[field] += F(
z).size_array[field];
676template <
class Fragment>
678 uint root = this->root();
679 return root ? sizeLeft(root, field) +
size(root, field) + sizeRight(root, field) : 0;
683template <
class Fragment>
713 n =
pt->data.next(
n);
717 n =
pt->data.previous(
n);
752 n =
pt->data.next(
n);
756 n =
pt->data.previous(
n);
784 inline bool isEmpty()
const {
return data.head->node_count == 0; }
810 return data.erase_single(
f);
827 {
data.setSize(node, new_size, field);
828 if (node != 0 && field == 0) {
Fragment * fragment(uint index)
void setRoot(uint new_root)
bool isRoot(uint index) const
uint erase_single(uint f)
const Fragment * fragment(uint index) const
uint sizeLeft(uint node, uint field=0) const
void setSize(uint node, int new_size, uint field=0)
uint previous(uint n) const
uint maximum(uint n) const
int length(uint field=0) const
const Fragment & F(uint index) const
bool isValid(uint n) const
uint position(uint node, uint field=0) const
uint sizeRight(uint node, uint field=0) const
uint minimum(uint n) const
uint size(uint node, uint field=0) const
uint insert_single(int key, uint length)
uint findNode(int k, uint field=0) const
const Fragment * value() const
ConstIterator(const ConstIterator &it)
bool operator!=(const ConstIterator &it) const
bool operator==(const ConstIterator &it) const
ConstIterator & operator--()
ConstIterator(const QFragmentMap *p, int node)
ConstIterator & operator++()
bool operator<(const ConstIterator &it) const
ConstIterator(const Iterator &it)
const Fragment * operator*() const
const Fragment * operator->() const
Iterator(QFragmentMap *p, int node)
const Fragment * operator*() const
const Fragment * value() const
Iterator(const Iterator &it)
bool operator<(const Iterator &it) const
bool operator==(const Iterator &it) const
bool operator!=(const Iterator &it) const
const Fragment * operator->() const
ConstIterator begin() const
uint position(uint node, uint field=0) const
uint insert_single(int key, uint length)
const Fragment * fragment(uint index) const
void setSize(uint node, int new_size, uint field=0)
ConstIterator last() const
uint previous(uint n) const
bool isValid(uint n) const
ConstIterator end() const
ConstIterator find(int k, uint field=0) const
Iterator find(int k, uint field=0)
uint erase_single(uint f)
Fragment * fragment(uint index)
uint findNode(int k, uint field=0) const
uint size(uint node, uint field=0) const
int length(uint field=0) const
quint32 size_left_array[N]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
CalculateGrowingBlockSizeResult qCalculateGrowingBlockSize(qsizetype elementCount, qsizetype elementSize, qsizetype headerSize) noexcept
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
Q_CHECK_PTR(a=new int[80])
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent