Qt 4.8
Classes | Public Types | Public Functions | Public Variables | Private Types | Private Functions | List of all members
QFragmentMapData< Fragment > Class Template Reference

#include <qfragmentmap_p.h>

Classes

class  Header
 

Public Types

enum  { fragmentSize = sizeof(Fragment) }
 

Public Functions

uint erase_single (uint f)
 
Fragment & F (uint index)
 
const Fragment & F (uint index) const
 
uint findNode (int k, uint field=0) const
 
Fragment * fragment (uint index)
 
const Fragment * fragment (uint index) const
 
void init ()
 
uint insert_single (int key, uint length)
 
bool isRoot (uint index) const
 
bool isValid (uint n) const
 
int length (uint field=0) const
 
uint maximum (uint n) const
 
uint minimum (uint n) const
 
uint next (uint n) const
 
uint position (uint node, uint field=0) const
 
uint previous (uint n) const
 
 QFragmentMapData ()
 
uint root () const
 
void setRoot (uint new_root)
 
void setSize (uint node, int new_size, uint field=0)
 
uint size (uint node, uint field=0) const
 
uint sizeLeft (uint node, uint field=0) const
 
uint sizeRight (uint node, uint field=0) const
 
 ~QFragmentMapData ()
 

Public Variables

union {
   Fragment *   fragments
 
   Header *   head
 
}; 
 

Private Types

enum  Color { Red, Black }
 

Private Functions

uint createFragment ()
 
void freeFragment (uint f)
 
void rebalance (uint x)
 
void removeAndRebalance (uint z)
 
void rotateLeft (uint x)
 
void rotateRight (uint x)
 

Detailed Description

template<class Fragment>
class QFragmentMapData< Fragment >

Definition at line 77 of file qfragmentmap_p.h.

Enumerations

◆ anonymous enum

template<class Fragment>
anonymous enum
Enumerator
fragmentSize 

Definition at line 97 of file qfragmentmap_p.h.

97 {fragmentSize = sizeof(Fragment) };

◆ Color

template<class Fragment>
enum QFragmentMapData::Color
private
Enumerator
Red 
Black 

Definition at line 79 of file qfragmentmap_p.h.

Constructors and Destructors

◆ QFragmentMapData()

template<class Fragment >
QFragmentMapData< Fragment >::QFragmentMapData ( )

Definition at line 220 of file qfragmentmap_p.h.

221  : fragments(0)
222 {
223  init();
224 }
Fragment * fragments

◆ ~QFragmentMapData()

template<class Fragment >
QFragmentMapData< Fragment >::~QFragmentMapData ( )

Definition at line 247 of file qfragmentmap_p.h.

248 {
249  free(fragments);
250 }
Fragment * fragments

Functions

◆ createFragment()

template<class Fragment >
uint QFragmentMapData< Fragment >::createFragment ( )
private

Definition at line 253 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::insert_single().

254 {
256 
257  uint freePos = head->freelist;
258  if (freePos == head->allocated) {
259  // need to create some free space
260  uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
261  Q_ASSERT(needed/fragmentSize > head->allocated);
262  Fragment *newFragments = (Fragment *)realloc(fragments, needed);
263  Q_CHECK_PTR(newFragments);
264  fragments = newFragments;
265  head->allocated = needed/fragmentSize;
266  F(freePos).right = 0;
267  }
268 
269  uint nextPos = F(freePos).right;
270  if (!nextPos) {
271  nextPos = freePos+1;
272  if (nextPos < head->allocated)
273  F(nextPos).right = 0;
274  }
275 
276  head->freelist = nextPos;
277 
278  ++head->node_count;
279 
280  return freePos;
281 }
Fragment * fragments
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int qAllocMore(int alloc, int extra)
Definition: qbytearray.cpp:70
unsigned int uint
Definition: qglobal.h:996
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
Fragment & F(uint index)

◆ erase_single()

template<class Fragment >
uint QFragmentMapData< Fragment >::erase_single ( uint  f)

Definition at line 461 of file qfragmentmap_p.h.

462 {
463  uint w = previous(z);
464  uint y = z;
465  uint x;
466  uint p;
467 
468  if (!F(y).left) {
469  x = F(y).right;
470  } else if (!F(y).right) {
471  x = F(y).left;
472  } else {
473  y = F(y).right;
474  while (F(y).left)
475  y = F(y).left;
476  x = F(y).right;
477  }
478 
479  if (y != z) {
480  F(F(z).left).parent = y;
481  F(y).left = F(z).left;
482  for (uint field = 0; field < Fragment::size_array_max; ++field)
483  F(y).size_left_array[field] = F(z).size_left_array[field];
484  if (y != F(z).right) {
485  /*
486  z y
487  / \ / \
488  a b a b
489  / /
490  ... --> ...
491  / /
492  y x
493  / \
494  0 x
495  */
496  p = F(y).parent;
497  if (x)
498  F(x).parent = p;
499  F(p).left = x;
500  F(y).right = F(z).right;
501  F(F(z).right).parent = y;
502  uint n = p;
503  while (n != y) {
504  for (uint field = 0; field < Fragment::size_array_max; ++field)
505  F(n).size_left_array[field] -= F(y).size_array[field];
506  n = F(n).parent;
507  }
508  } else {
509  /*
510  z y
511  / \ / \
512  a y --> a x
513  / \
514  0 x
515  */
516  p = y;
517  }
518  uint zp = F(z).parent;
519  if (!zp) {
520  Q_ASSERT(head->root == z);
521  head->root = y;
522  } else if (F(zp).left == z) {
523  F(zp).left = y;
524  for (uint field = 0; field < Fragment::size_array_max; ++field)
525  F(zp).size_left_array[field] -= F(z).size_array[field];
526  } else {
527  F(zp).right = y;
528  }
529  F(y).parent = zp;
530  // Swap the colors
531  uint c = F(y).color;
532  F(y).color = F(z).color;
533  F(z).color = c;
534  y = z;
535  } else {
536  /*
537  p p p p
538  / / \ \
539  z --> x z --> x
540  | |
541  x x
542  */
543  p = F(z).parent;
544  if (x)
545  F(x).parent = p;
546  if (!p) {
547  Q_ASSERT(head->root == z);
548  head->root = x;
549  } else if (F(p).left == z) {
550  F(p).left = x;
551  for (uint field = 0; field < Fragment::size_array_max; ++field)
552  F(p).size_left_array[field] -= F(z).size_array[field];
553  } else {
554  F(p).right = x;
555  }
556  }
557  uint n = z;
558  while (F(n).parent) {
559  uint p = F(n).parent;
560  if (F(p).left == n) {
561  for (uint field = 0; field < Fragment::size_array_max; ++field)
562  F(p).size_left_array[field] -= F(z).size_array[field];
563  }
564  n = p;
565  }
566 
567  freeFragment(z);
568 
569 
570  if (F(y).color != Red) {
571  while (F(x).parent && (x == 0 || F(x).color == Black)) {
572  if (x == F(p).left) {
573  uint w = F(p).right;
574  if (F(w).color == Red) {
575  F(w).color = Black;
576  F(p).color = Red;
577  rotateLeft(p);
578  w = F(p).right;
579  }
580  if ((F(w).left == 0 || F(F(w).left).color == Black) &&
581  (F(w).right == 0 || F(F(w).right).color == Black)) {
582  F(w).color = Red;
583  x = p;
584  p = F(x).parent;
585  } else {
586  if (F(w).right == 0 || F(F(w).right).color == Black) {
587  if (F(w).left)
588  F(F(w).left).color = Black;
589  F(w).color = Red;
590  rotateRight(F(p).right);
591  w = F(p).right;
592  }
593  F(w).color = F(p).color;
594  F(p).color = Black;
595  if (F(w).right)
596  F(F(w).right).color = Black;
597  rotateLeft(p);
598  break;
599  }
600  } else {
601  uint w = F(p).left;
602  if (F(w).color == Red) {
603  F(w).color = Black;
604  F(p).color = Red;
605  rotateRight(p);
606  w = F(p).left;
607  }
608  if ((F(w).right == 0 || F(F(w).right).color == Black) &&
609  (F(w).left == 0 || F(F(w).left).color == Black)) {
610  F(w).color = Red;
611  x = p;
612  p = F(x).parent;
613  } else {
614  if (F(w).left == 0 || F(F(w).left).color == Black) {
615  if (F(w).right)
616  F(F(w).right).color = Black;
617  F(w).color = Red;
618  rotateLeft(F(p).left);
619  w = F(p).left;
620  }
621  F(w).color = F(p).color;
622  F(p).color = Black;
623  if (F(w).left)
624  F(F(w).left).color = Black;
625  rotateRight(p);
626  break;
627  }
628  }
629  }
630  if (x)
631  F(x).color = Black;
632  }
633 
634  return w;
635 }
unsigned char c[8]
Definition: qnumeric_p.h:62
void freeFragment(uint f)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void rotateLeft(uint x)
unsigned int uint
Definition: qglobal.h:996
uint previous(uint n) const
Fragment & F(uint index)
void rotateRight(uint x)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ F() [1/2]

template<class Fragment>
Fragment& QFragmentMapData< Fragment >::F ( uint  index)
inline

◆ F() [2/2]

template<class Fragment>
const Fragment& QFragmentMapData< Fragment >::F ( uint  index) const
inline

Definition at line 112 of file qfragmentmap_p.h.

112 { return fragments[index] ; }
Fragment * fragments
quint16 index

◆ findNode()

template<class Fragment >
uint QFragmentMapData< Fragment >::findNode ( int  k,
uint  field = 0 
) const

Definition at line 638 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::insert_single().

639 {
640  Q_ASSERT(field < Fragment::size_array_max);
641  uint x = root();
642 
643  uint s = k;
644  while (x) {
645  if (sizeLeft(x, field) <= s) {
646  if (s < sizeLeft(x, field) + size(x, field))
647  return x;
648  s -= sizeLeft(x, field) + size(x, field);
649  x = F(x).right;
650  } else {
651  x = F(x).left;
652  }
653  }
654  return 0;
655 }
uint sizeLeft(uint node, uint field=0) const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
uint root() const
unsigned int uint
Definition: qglobal.h:996
uint size(uint node, uint field=0) const
Fragment & F(uint index)

◆ fragment() [1/2]

template<class Fragment>
Fragment* QFragmentMapData< Fragment >::fragment ( uint  index)
inline

◆ fragment() [2/2]

template<class Fragment>
const Fragment* QFragmentMapData< Fragment >::fragment ( uint  index) const
inline

Definition at line 106 of file qfragmentmap_p.h.

106  {
107  return (fragments + index);
108  }
Fragment * fragments
quint16 index

◆ freeFragment()

template<class Fragment >
void QFragmentMapData< Fragment >::freeFragment ( uint  f)
private

Definition at line 284 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::erase_single().

285 {
286  F(i).right = head->freelist;
287  head->freelist = i;
288 
289  --head->node_count;
290 }
Fragment & F(uint index)

◆ init()

template<class Fragment >
void QFragmentMapData< Fragment >::init ( )

Definition at line 227 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::QFragmentMapData().

228 {
229  // the following code will realloc an existing fragment or create a new one.
230  // it will also ignore errors when shrinking an existing fragment.
231  Fragment *newFragments = (Fragment *)realloc(fragments, 64*fragmentSize);
232  if (newFragments) {
233  fragments = newFragments;
234  head->allocated = 64;
235  }
237 
238  head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p');
239  head->root = 0;
240  head->freelist = 1;
241  head->node_count = 0;
242  // mark all items to the right as unused
243  F(head->freelist).right = 0;
244 }
Fragment * fragments
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
Fragment & F(uint index)
unsigned int quint32
Definition: qglobal.h:938

◆ insert_single()

template<class Fragment >
uint QFragmentMapData< Fragment >::insert_single ( int  key,
uint  length 
)

Definition at line 658 of file qfragmentmap_p.h.

659 {
660  Q_ASSERT(!findNode(key) || (int)this->position(findNode(key)) == key);
661 
662  uint z = createFragment();
663 
664  F(z).left = 0;
665  F(z).right = 0;
666  F(z).size_array[0] = length;
667  for (uint field = 1; field < Fragment::size_array_max; ++field)
668  F(z).size_array[field] = 1;
669  for (uint field = 0; field < Fragment::size_array_max; ++field)
670  F(z).size_left_array[field] = 0;
671 
672  uint y = 0;
673  uint x = root();
674 
675  Q_ASSERT(!x || F(x).parent == 0);
676 
677  uint s = key;
678  bool right = false;
679  while (x) {
680  y = x;
681  if (s <= F(x).size_left_array[0]) {
682  x = F(x).left;
683  right = false;
684  } else {
685  s -= F(x).size_left_array[0] + F(x).size_array[0];
686  x = F(x).right;
687  right = true;
688  }
689  }
690 
691  F(z).parent = y;
692  if (!y) {
693  head->root = z;
694  } else if (!right) {
695  F(y).left = z;
696  for (uint field = 0; field < Fragment::size_array_max; ++field)
697  F(y).size_left_array[field] = F(z).size_array[field];
698  } else {
699  F(y).right = z;
700  }
701  while (y && F(y).parent) {
702  uint p = F(y).parent;
703  if (F(p).left == y) {
704  for (uint field = 0; field < Fragment::size_array_max; ++field)
705  F(p).size_left_array[field] += F(z).size_array[field];
706  }
707  y = p;
708  }
709  rebalance(z);
710 
711  return z;
712 }
uint findNode(int k, uint field=0) const
uint position(uint node, uint field=0) const
void rebalance(uint x)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
int length(uint field=0) const
uint root() const
unsigned int uint
Definition: qglobal.h:996
Fragment & F(uint index)
int key
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ isRoot()

template<class Fragment>
bool QFragmentMapData< Fragment >::isRoot ( uint  index) const
inline

Definition at line 114 of file qfragmentmap_p.h.

114  {
115  return !fragment(index)->parent;
116  }
Fragment * fragment(uint index)
quint16 index

◆ isValid()

template<class Fragment>
bool QFragmentMapData< Fragment >::isValid ( uint  n) const
inline

Definition at line 198 of file qfragmentmap_p.h.

198  {
199  return n > 0 && n != head->freelist;
200  }

◆ length()

template<class Fragment >
int QFragmentMapData< Fragment >::length ( uint  field = 0) const

Definition at line 716 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::insert_single().

716  {
717  uint root = this->root();
718  return root ? sizeLeft(root, field) + size(root, field) + sizeRight(root, field) : 0;
719 }
uint sizeLeft(uint node, uint field=0) const
uint sizeRight(uint node, uint field=0) const
uint root() const
unsigned int uint
Definition: qglobal.h:996
uint size(uint node, uint field=0) const

◆ maximum()

template<class Fragment>
uint QFragmentMapData< Fragment >::maximum ( uint  n) const
inline

Definition at line 180 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::previous().

180  {
181  while (n && fragment(n)->right)
182  n = fragment(n)->right;
183  return n;
184  }
Fragment * fragment(uint index)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)

◆ minimum()

template<class Fragment>
uint QFragmentMapData< Fragment >::minimum ( uint  n) const
inline

Definition at line 174 of file qfragmentmap_p.h.

174  {
175  while (n && fragment(n)->left)
176  n = fragment(n)->left;
177  return n;
178  }
Fragment * fragment(uint index)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ next()

template<class Fragment >
uint QFragmentMapData< Fragment >::next ( uint  n) const

Definition at line 294 of file qfragmentmap_p.h.

294  {
295  Q_ASSERT(n);
296  if (F(n).right) {
297  n = F(n).right;
298  while (F(n).left)
299  n = F(n).left;
300  } else {
301  uint y = F(n).parent;
302  while (F(n).parent && n == F(y).right) {
303  n = y;
304  y = F(y).parent;
305  }
306  n = y;
307  }
308  return n;
309 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
unsigned int uint
Definition: qglobal.h:996
Fragment & F(uint index)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ position()

template<class Fragment>
uint QFragmentMapData< Fragment >::position ( uint  node,
uint  field = 0 
) const
inline

Definition at line 118 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::insert_single(), QFragmentMap< Fragment >::Iterator::operator<(), and QFragmentMap< Fragment >::ConstIterator::operator<().

118  {
119  Q_ASSERT(field < Fragment::size_array_max);
120  const Fragment *f = fragment(node);
121  uint offset = f->size_left_array[field];
122  while (f->parent) {
123  uint p = f->parent;
124  f = fragment(p);
125  if (f->right == node)
126  offset += f->size_left_array[field] + f->size_array[field];
127  node = p;
128  }
129  return offset;
130  }
Fragment * fragment(uint index)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned int uint
Definition: qglobal.h:996

◆ previous()

template<class Fragment >
uint QFragmentMapData< Fragment >::previous ( uint  n) const

Definition at line 312 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::erase_single().

312  {
313  if (!n)
314  return maximum(root());
315 
316  if (F(n).left) {
317  n = F(n).left;
318  while (F(n).right)
319  n = F(n).right;
320  } else {
321  uint y = F(n).parent;
322  while (F(n).parent && n == F(y).left) {
323  n = y;
324  y = F(y).parent;
325  }
326  n = y;
327  }
328  return n;
329 }
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
uint root() const
unsigned int uint
Definition: qglobal.h:996
Fragment & F(uint index)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
uint maximum(uint n) const

◆ rebalance()

template<class Fragment >
void QFragmentMapData< Fragment >::rebalance ( uint  x)
private

Definition at line 406 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::insert_single().

407 {
408  F(x).color = Red;
409 
410  while (F(x).parent && F(F(x).parent).color == Red) {
411  uint p = F(x).parent;
412  uint pp = F(p).parent;
413  Q_ASSERT(pp);
414  if (p == F(pp).left) {
415  uint y = F(pp).right;
416  if (y && F(y).color == Red) {
417  F(p).color = Black;
418  F(y).color = Black;
419  F(pp).color = Red;
420  x = pp;
421  } else {
422  if (x == F(p).right) {
423  x = p;
424  rotateLeft(x);
425  p = F(x).parent;
426  pp = F(p).parent;
427  }
428  F(p).color = Black;
429  if (pp) {
430  F(pp).color = Red;
431  rotateRight(pp);
432  }
433  }
434  } else {
435  uint y = F(pp).left;
436  if (y && F(y).color == Red) {
437  F(p).color = Black;
438  F(y).color = Black;
439  F(pp).color = Red;
440  x = pp;
441  } else {
442  if (x == F(p).left) {
443  x = p;
444  rotateRight(x);
445  p = F(x).parent;
446  pp = F(p).parent;
447  }
448  F(p).color = Black;
449  if (pp) {
450  F(pp).color = Red;
451  rotateLeft(pp);
452  }
453  }
454  }
455  }
456  F(root()).color = Black;
457 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
uint root() const
void rotateLeft(uint x)
unsigned int uint
Definition: qglobal.h:996
Fragment & F(uint index)
void rotateRight(uint x)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ removeAndRebalance()

template<class Fragment>
void QFragmentMapData< Fragment >::removeAndRebalance ( uint  z)
private

◆ root()

template<class Fragment>
uint QFragmentMapData< Fragment >::root ( ) const
inline

◆ rotateLeft()

template<class Fragment >
void QFragmentMapData< Fragment >::rotateLeft ( uint  x)
private

Definition at line 340 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::erase_single(), and QFragmentMapData< QTextBlockData >::rebalance().

341 {
342  uint p = F(x).parent;
343  uint y = F(x).right;
344 
345 
346  if (y) {
347  F(x).right = F(y).left;
348  if (F(y).left)
349  F(F(y).left).parent = x;
350  F(y).left = x;
351  F(y).parent = p;
352  } else {
353  F(x).right = 0;
354  }
355  if (!p) {
356  Q_ASSERT(head->root == x);
357  head->root = y;
358  }
359  else if (x == F(p).left)
360  F(p).left = y;
361  else
362  F(p).right = y;
363  F(x).parent = y;
364  for (uint field = 0; field < Fragment::size_array_max; ++field)
365  F(y).size_left_array[field] += F(x).size_left_array[field] + F(x).size_array[field];
366 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned int uint
Definition: qglobal.h:996
Fragment & F(uint index)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ rotateRight()

template<class Fragment >
void QFragmentMapData< Fragment >::rotateRight ( uint  x)
private

Definition at line 377 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::erase_single(), and QFragmentMapData< QTextBlockData >::rebalance().

378 {
379  uint y = F(x).left;
380  uint p = F(x).parent;
381 
382  if (y) {
383  F(x).left = F(y).right;
384  if (F(y).right)
385  F(F(y).right).parent = x;
386  F(y).right = x;
387  F(y).parent = p;
388  } else {
389  F(x).left = 0;
390  }
391  if (!p) {
392  Q_ASSERT(head->root == x);
393  head->root = y;
394  }
395  else if (x == F(p).right)
396  F(p).right = y;
397  else
398  F(p).left = y;
399  F(x).parent = y;
400  for (uint field = 0; field < Fragment::size_array_max; ++field)
401  F(x).size_left_array[field] -= F(y).size_left_array[field] + F(y).size_array[field];
402 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
unsigned int uint
Definition: qglobal.h:996
Fragment & F(uint index)

◆ setRoot()

template<class Fragment>
void QFragmentMapData< Fragment >::setRoot ( uint  new_root)
inline

Definition at line 193 of file qfragmentmap_p.h.

193  {
194  Q_ASSERT(!head->root || !fragment(new_root)->parent);
195  head->root = new_root;
196  }
Fragment * fragment(uint index)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ setSize()

template<class Fragment>
void QFragmentMapData< Fragment >::setSize ( uint  node,
int  new_size,
uint  field = 0 
)
inline

Definition at line 154 of file qfragmentmap_p.h.

154  {
155  Q_ASSERT(field < Fragment::size_array_max);
156  Fragment *f = fragment(node);
157  int diff = new_size - f->size_array[field];
158  f->size_array[field] = new_size;
159  while (f->parent) {
160  uint p = f->parent;
161  f = fragment(p);
162  if (f->left == node)
163  f->size_left_array[field] += diff;
164  node = p;
165  }
166  }
Fragment * fragment(uint index)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned int uint
Definition: qglobal.h:996
static Bigint * diff(Bigint *a, Bigint *b)

◆ size()

template<class Fragment>
uint QFragmentMapData< Fragment >::size ( uint  node,
uint  field = 0 
) const
inline

Definition at line 149 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::findNode(), and QFragmentMapData< QTextBlockData >::length().

149  {
150  Q_ASSERT(field < Fragment::size_array_max);
151  return fragment(node)->size_array[field];
152  }
Fragment * fragment(uint index)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ sizeLeft()

template<class Fragment>
uint QFragmentMapData< Fragment >::sizeLeft ( uint  node,
uint  field = 0 
) const
inline

Definition at line 143 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::findNode(), and QFragmentMapData< QTextBlockData >::length().

143  {
144  Q_ASSERT(field < Fragment::size_array_max);
145  return fragment(node)->size_left_array[field];
146  }
Fragment * fragment(uint index)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ sizeRight()

template<class Fragment>
uint QFragmentMapData< Fragment >::sizeRight ( uint  node,
uint  field = 0 
) const
inline

Definition at line 131 of file qfragmentmap_p.h.

Referenced by QFragmentMapData< QTextBlockData >::length().

131  {
132  Q_ASSERT(field < Fragment::size_array_max);
133  uint sr = 0;
134  const Fragment *f = fragment(node);
135  node = f->right;
136  while (node) {
137  f = fragment(node);
138  sr += f->size_left_array[field] + f->size_array[field];
139  node = f->right;
140  }
141  return sr;
142  }
Fragment * fragment(uint index)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned int uint
Definition: qglobal.h:996

Properties

◆ @281

union { ... }

◆ fragments

template<class Fragment>
Fragment* QFragmentMapData< Fragment >::fragments

◆ head

template<class Fragment>
Header* QFragmentMapData< Fragment >::head

The documentation for this class was generated from the following file: