LibreOffice Module sc (master)  1
segmenttree.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <segmenttree.hxx>
21 #include <o3tl/safeint.hxx>
22 #include <mdds/flat_segment_tree.hpp>
23 #include <sal/log.hxx>
24 #include <algorithm>
25 #include <limits>
26 #include <string_view>
27 #include <global.hxx>
28 
29 using ::std::numeric_limits;
30 
31 namespace {
32 
33 template<typename ValueType_, typename ExtValueType_ = ValueType_>
34 class ScFlatSegmentsImpl
35 {
36 public:
37  typedef ValueType_ ValueType;
38  typedef ExtValueType_ ExtValueType;
39 
40  struct RangeData
41  {
42  SCCOLROW mnPos1;
43  SCCOLROW mnPos2;
44  ValueType mnValue;
45  };
46 
47  ScFlatSegmentsImpl(SCCOLROW nMax, ValueType nDefault);
48  ScFlatSegmentsImpl(const ScFlatSegmentsImpl& r);
49 
50  bool setValue(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue);
51  void setValueIf(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue, const std::function<bool(ValueType)>& rPredicate);
52  ValueType getValue(SCCOLROW nPos);
53  ExtValueType getSumValue(SCCOLROW nPos1, SCCOLROW nPos2);
54  bool getRangeData(SCCOLROW nPos, RangeData& rData);
55  bool getRangeDataLeaf(SCCOLROW nPos, RangeData& rData);
56  void removeSegment(SCCOLROW nPos1, SCCOLROW nPos2);
57  void insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary);
58 
59  SCCOLROW findLastTrue(ValueType nValue) const;
60 
61  // range iteration
62  bool getFirst(RangeData& rData);
63  bool getNext(RangeData& rData);
64 
65  void enableTreeSearch(bool b)
66  {
67  mbTreeSearchEnabled = b;
68  }
69 
70  void makeReady();
71 
72 private:
73  typedef ::mdds::flat_segment_tree<SCCOLROW, ValueType> fst_type;
74  fst_type maSegments;
75  typename fst_type::const_iterator maItr;
76 
77  bool mbTreeSearchEnabled:1;
78 };
79 
80 }
81 
82 template<typename ValueType_, typename ExtValueType_>
83 ScFlatSegmentsImpl<ValueType_, ExtValueType_>::ScFlatSegmentsImpl(SCCOLROW nMax, ValueType nDefault) :
84  maSegments(0, nMax+1, nDefault),
85  mbTreeSearchEnabled(true)
86 {
87 }
88 
89 template<typename ValueType_, typename ExtValueType_>
90 ScFlatSegmentsImpl<ValueType_, ExtValueType_>::ScFlatSegmentsImpl(const ScFlatSegmentsImpl<ValueType_, ExtValueType_>& r) :
91  maSegments(r.maSegments),
92  mbTreeSearchEnabled(r.mbTreeSearchEnabled)
93 {
94 }
95 
96 template<typename ValueType_, typename ExtValueType_>
97 bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::setValue(SCCOLROW nPos1, SCCOLROW nPos2, ValueType nValue)
98 {
99  ::std::pair<typename fst_type::const_iterator, bool> ret;
100  ret = maSegments.insert(maItr, nPos1, nPos2+1, nValue);
101  maItr = ret.first;
102  return ret.second;
103 }
104 
105 template<typename ValueType_, typename ExtValueType_>
106 void ScFlatSegmentsImpl<ValueType_, ExtValueType_>::setValueIf(SCCOLROW nPos1, SCCOLROW nPos2,
107  ValueType nValue, const std::function<bool(ValueType)>& rPredicate)
108 {
109  SCCOLROW nCurrentStartRow = nPos1;
110  while (nCurrentStartRow <= nPos2)
111  {
112  RangeData aRangeData;
113  getRangeData(nCurrentStartRow, aRangeData);
114  if (rPredicate(aRangeData.mnValue))
115  {
116  // set value from current iteration point on, til end of range.
117  // Note that aRangeData may well contain much lower values for nPos1
118  setValue(nCurrentStartRow, std::min<SCCOLROW>(nPos2, aRangeData.mnPos2), nValue);
119  }
120 
121  // even if nPos2 is bigger than nPos2 this should terminate the loop
122  nCurrentStartRow = aRangeData.mnPos2 + 1;
123  }
124 }
125 
126 template<typename ValueType_, typename ExtValueType_>
127 typename ScFlatSegmentsImpl<ValueType_, ExtValueType_>::ValueType ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getValue(SCCOLROW nPos)
128 {
129  ValueType nValue = 0;
130  if (!mbTreeSearchEnabled)
131  {
132  maSegments.search(nPos, nValue);
133  return nValue;
134  }
135 
136  if (!maSegments.is_tree_valid())
137  {
139  maSegments.build_tree();
140  }
141 
142  maSegments.search_tree(nPos, nValue);
143  return nValue;
144 }
145 
146 template<typename ValueType_, typename ExtValueType_>
147 typename ScFlatSegmentsImpl<ValueType_, ExtValueType_>::ExtValueType
148 ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getSumValue(SCCOLROW nPos1, SCCOLROW nPos2)
149 {
150  if (mbTreeSearchEnabled)
151  {
152 
153  if (!maSegments.is_tree_valid())
154  {
156  maSegments.build_tree();
157  }
158 
159  RangeData aData;
160  auto [it, found] = maSegments.search_tree(nPos1, aData.mnValue, &aData.mnPos1, &aData.mnPos2);
161  if (!found)
162  return 0;
163  aData.mnPos2 = aData.mnPos2-1; // end point is not inclusive.
164 
165  sal_uInt32 nValue = 0;
166 
167  SCROW nCurPos = nPos1;
168  SCROW nEndPos = aData.mnPos2;
169  while (nEndPos <= nPos2)
170  {
171  sal_uInt32 nRes;
172  if (o3tl::checked_multiply<sal_uInt32>(aData.mnValue, nEndPos - nCurPos + 1, nRes))
173  {
174  SAL_WARN("sc.core", "row height overflow");
175  nRes = SAL_MAX_INT32;
176  }
177  nValue = o3tl::saturating_add(nValue, nRes);
178  nCurPos = nEndPos + 1;
179  auto itPair = maSegments.search(it, nCurPos, aData.mnValue, &aData.mnPos1, &aData.mnPos2);
180  if (!itPair.second)
181  break;
182  it = itPair.first;
183  aData.mnPos2 = aData.mnPos2-1; // end point is not inclusive.
184  nEndPos = aData.mnPos2;
185  }
186  if (nCurPos <= nPos2)
187  {
188  nEndPos = ::std::min(nEndPos, nPos2);
189  sal_uInt32 nRes;
190  if (o3tl::checked_multiply<sal_uInt32>(aData.mnValue, nEndPos - nCurPos + 1, nRes))
191  {
192  SAL_WARN("sc.core", "row height overflow");
193  nRes = SAL_MAX_INT32;
194  }
195  nValue = o3tl::saturating_add(nValue, nRes);
196  }
197  return nValue;
198  }
199  else
200  {
201  RangeData aData;
202  if (!getRangeDataLeaf(nPos1, aData))
203  return 0;
204 
205  sal_uInt32 nValue = 0;
206 
207  SCROW nCurPos = nPos1;
208  SCROW nEndPos = aData.mnPos2;
209  while (nEndPos <= nPos2)
210  {
211  sal_uInt32 nRes;
212  if (o3tl::checked_multiply<sal_uInt32>(aData.mnValue, nEndPos - nCurPos + 1, nRes))
213  {
214  SAL_WARN("sc.core", "row height overflow");
215  nRes = SAL_MAX_INT32;
216  }
217  nValue = o3tl::saturating_add(nValue, nRes);
218  nCurPos = nEndPos + 1;
219  if (!getRangeDataLeaf(nCurPos, aData))
220  break;
221 
222  nEndPos = aData.mnPos2;
223  }
224  if (nCurPos <= nPos2)
225  {
226  nEndPos = ::std::min(nEndPos, nPos2);
227  sal_uInt32 nRes;
228  if (o3tl::checked_multiply<sal_uInt32>(aData.mnValue, nEndPos - nCurPos + 1, nRes))
229  {
230  SAL_WARN("sc.core", "row height overflow");
231  nRes = SAL_MAX_INT32;
232  }
233  nValue = o3tl::saturating_add(nValue, nRes);
234  }
235  return nValue;
236  }
237 }
238 
239 template<typename ValueType_, typename ExtValueType_>
240 bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getRangeData(SCCOLROW nPos, RangeData& rData)
241 {
242  if (!mbTreeSearchEnabled)
243  return getRangeDataLeaf(nPos, rData);
244 
245  if (!maSegments.is_tree_valid())
246  {
248  maSegments.build_tree();
249  }
250 
251  auto [it,found] = maSegments.search_tree(nPos, rData.mnValue, &rData.mnPos1, &rData.mnPos2);
252  if (!found)
253  return false;
254  maItr = it; // cache the iterator to speed up ForwardIterator.
255  rData.mnPos2 = rData.mnPos2-1; // end point is not inclusive.
256  return true;
257 }
258 
259 template<typename ValueType_, typename ExtValueType_>
260 bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getRangeDataLeaf(SCCOLROW nPos, RangeData& rData)
261 {
262  // Conduct leaf-node only search. Faster when searching between range insertion.
263  const ::std::pair<typename fst_type::const_iterator, bool> &ret =
264  maSegments.search(maItr, nPos, rData.mnValue, &rData.mnPos1, &rData.mnPos2);
265 
266  if (!ret.second)
267  return false;
268 
269  maItr = ret.first;
270 
271  rData.mnPos2 = rData.mnPos2-1; // end point is not inclusive.
272  return true;
273 }
274 
275 template<typename ValueType_, typename ExtValueType_>
276 void ScFlatSegmentsImpl<ValueType_, ExtValueType_>::removeSegment(SCCOLROW nPos1, SCCOLROW nPos2)
277 {
278  maSegments.shift_left(nPos1, nPos2);
279  maItr = maSegments.begin();
280 }
281 
282 template<typename ValueType_, typename ExtValueType_>
283 void ScFlatSegmentsImpl<ValueType_, ExtValueType_>::insertSegment(SCCOLROW nPos, SCCOLROW nSize, bool bSkipStartBoundary)
284 {
285  maSegments.shift_right(nPos, nSize, bSkipStartBoundary);
286  maItr = maSegments.begin();
287 }
288 
289 template<typename ValueType_, typename ExtValueType_>
290 SCCOLROW ScFlatSegmentsImpl<ValueType_, ExtValueType_>::findLastTrue(ValueType nValue) const
291 {
292  SCCOLROW nPos = numeric_limits<SCCOLROW>::max(); // position not found.
293  typename fst_type::const_reverse_iterator itr = maSegments.rbegin(), itrEnd = maSegments.rend();
294  // Note that when searching in reverse direction, we need to skip the first
295  // node, since the right-most leaf node does not store a valid value.
296  for (++itr; itr != itrEnd; ++itr)
297  {
298  if (itr->second != nValue)
299  {
300  nPos = (--itr)->first - 1;
301  break;
302  }
303  }
304  return nPos;
305 }
306 
307 template<typename ValueType_, typename ExtValueType_>
308 bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getFirst(RangeData& rData)
309 {
310  maItr = maSegments.begin();
311  return getNext(rData);
312 }
313 
314 template<typename ValueType_, typename ExtValueType_>
315 bool ScFlatSegmentsImpl<ValueType_, ExtValueType_>::getNext(RangeData& rData)
316 {
317  typename fst_type::const_iterator itrEnd = maSegments.end();
318  if (maItr == itrEnd)
319  return false;
320 
321  rData.mnPos1 = maItr->first;
322  rData.mnValue = maItr->second;
323 
324  ++maItr;
325  if (maItr == itrEnd)
326  return false;
327 
328  rData.mnPos2 = maItr->first - 1;
329  return true;
330 }
331 
332 template<typename ValueType_, typename ExtValueType_>
333 void ScFlatSegmentsImpl<ValueType_, ExtValueType_>::makeReady()
334 {
336  if (!maSegments.is_tree_valid())
337  maSegments.build_tree();
338 }
339 
340 class ScFlatUInt16SegmentsImpl : public ScFlatSegmentsImpl<sal_uInt16, sal_uInt32>
341 {
342 public:
343  explicit ScFlatUInt16SegmentsImpl(SCCOLROW nMax, sal_uInt16 nDefault) :
344  ScFlatSegmentsImpl<sal_uInt16, sal_uInt32>(nMax, nDefault)
345  {
346  }
347 };
348 
349 class ScFlatBoolSegmentsImpl : public ScFlatSegmentsImpl<bool>
350 {
351 public:
353  ScFlatSegmentsImpl<bool>(nMax, false)
354  {
355  }
356 
357  bool setTrue(SCCOLROW nPos1, SCCOLROW nPos2);
358  bool setFalse(SCCOLROW nPos1, SCCOLROW nPos2);
359 };
360 
362 {
363  return setValue(nPos1, nPos2, true);
364 }
365 
367 {
368  return setValue(nPos1, nPos2, false);
369 }
370 
372  mrSegs(rSegs), mnCurPos(0), mnLastPos(-1), mbCurValue(false)
373 {
374 }
375 
377 {
378  if (nPos >= mnCurPos)
379  // It can only go in a forward direction.
380  mnCurPos = nPos;
381 
382  if (mnCurPos > mnLastPos)
383  {
384  // position not in the current segment. Update the current value.
386  if (!mrSegs.getRangeData(mnCurPos, aData))
387  return false;
388 
389  mbCurValue = aData.mbValue;
390  mnLastPos = aData.mnRow2;
391  }
392 
393  rVal = mbCurValue;
394  return true;
395 }
396 
398  mrSegs(rSegs)
399 {
400 }
401 
403 {
404  ScFlatBoolSegmentsImpl::RangeData aData;
405  if (!mrSegs.mpImpl->getFirst(aData))
406  return false;
407 
408  rRange.mnRow1 = static_cast<SCROW>(aData.mnPos1);
409  rRange.mnRow2 = static_cast<SCROW>(aData.mnPos2);
410  rRange.mbValue = static_cast<bool>(aData.mnValue);
411  return true;
412 }
413 
415 {
416  ScFlatBoolSegmentsImpl::RangeData aData;
417  if (!mrSegs.mpImpl->getNext(aData))
418  return false;
419 
420  rRange.mnRow1 = static_cast<SCROW>(aData.mnPos1);
421  rRange.mnRow2 = static_cast<SCROW>(aData.mnPos2);
422  rRange.mbValue = static_cast<bool>(aData.mnValue);
423  return true;
424 }
425 
427  mpImpl(new ScFlatBoolSegmentsImpl(nMaxRow))
428 {
429 }
430 
432  mpImpl(new ScFlatBoolSegmentsImpl(*r.mpImpl))
433 {
434 }
435 
437 {
438 }
439 
441 {
442  return mpImpl->setTrue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
443 }
444 
446 {
447  return mpImpl->setFalse(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
448 }
449 
451 {
452  ScFlatBoolSegmentsImpl::RangeData aData;
453  if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nRow), aData))
454  return false;
455 
456  rData.mbValue = aData.mnValue;
457  rData.mnRow1 = static_cast<SCROW>(aData.mnPos1);
458  rData.mnRow2 = static_cast<SCROW>(aData.mnPos2);
459  return true;
460 }
461 
463 {
464  ScFlatBoolSegmentsImpl::RangeData aData;
465  if (!mpImpl->getRangeDataLeaf(static_cast<SCCOLROW>(nRow), aData))
466  return false;
467 
468  rData.mbValue = aData.mnValue;
469  rData.mnRow1 = static_cast<SCROW>(aData.mnPos1);
470  rData.mnRow2 = static_cast<SCROW>(aData.mnPos2);
471  return true;
472 }
473 
475 {
476  mpImpl->removeSegment(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
477 }
478 
480 {
481  mpImpl->insertSegment(static_cast<SCCOLROW>(nRow), static_cast<SCCOLROW>(nSize), true/*bSkipStartBoundary*/);
482 }
483 
485 {
486  return mpImpl->findLastTrue(false);
487 }
488 
490 {
491  mpImpl->makeReady();
492 }
493 
495 {
496  OString aOutput;
497  OString aSegment;
498  RangeData aRange;
499  SCROW nRow = 0;
500  while (getRangeData(nRow, aRange))
501  {
502  if (!nRow)
503  aSegment = (aRange.mbValue ? std::string_view("1") : std::string_view("0")) + OString::Concat(":");
504  else
505  aSegment.clear();
506 
507  aSegment += OString::number(aRange.mnRow2) + " ";
508  aOutput += aSegment;
509  nRow = aRange.mnRow2 + 1;
510  }
511 
512  return aOutput;
513 }
514 
516  mpImpl(new ScFlatBoolSegmentsImpl(nMaxCol))
517 {
518 }
519 
521  mpImpl(new ScFlatBoolSegmentsImpl(*r.mpImpl))
522 {
523 }
524 
526 {
527 }
528 
530 {
531  return mpImpl->setTrue(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2));
532 }
533 
535 {
536  return mpImpl->setFalse(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2));
537 }
538 
540 {
541  ScFlatBoolSegmentsImpl::RangeData aData;
542  if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nCol), aData))
543  return false;
544 
545  rData.mbValue = aData.mnValue;
546  rData.mnCol1 = static_cast<SCCOL>(aData.mnPos1);
547  rData.mnCol2 = static_cast<SCCOL>(aData.mnPos2);
548  return true;
549 }
550 
552 {
553  mpImpl->removeSegment(static_cast<SCCOLROW>(nCol1), static_cast<SCCOLROW>(nCol2));
554 }
555 
557 {
558  mpImpl->insertSegment(static_cast<SCCOLROW>(nCol), static_cast<SCCOLROW>(nSize), true/*bSkipStartBoundary*/);
559 }
560 
562 {
563  mpImpl->makeReady();
564 }
565 
567 {
568  OString aOutput;
569  OString aSegment;
570  RangeData aRange;
571  SCCOL nCol = 0;
572  while (getRangeData(nCol, aRange))
573  {
574  if (!nCol)
575  aSegment = (aRange.mbValue ? OString::Concat("1") : OString::Concat("0")) + OString::Concat(":");
576  else
577  aSegment.clear();
578 
579  aSegment += OString::number(aRange.mnCol2) + " ";
580  aOutput += aSegment;
581  nCol = aRange.mnCol2 + 1;
582  }
583 
584  return aOutput;
585 }
586 
588  mrSegs(rSegs), mnCurPos(0), mnLastPos(-1), mnCurValue(0)
589 {
590 }
591 
593 {
594  if (nPos >= mnCurPos)
595  // It can only go in a forward direction.
596  mnCurPos = nPos;
597 
598  if (mnCurPos > mnLastPos)
599  {
600  // position not in the current segment. Update the current value.
601  ScFlatUInt16SegmentsImpl::RangeData aData;
602  if (mnLastPos == -1)
603  {
604  // first time in this method, use the tree search based method
605  if (!mrSegs.mpImpl->getRangeData(mnCurPos, aData))
606  return false;
607  }
608  else
609  {
610  // but on subsequent calls, use the leaf method, which is faster
611  // because we have a cached iterator.
612  if (!mrSegs.mpImpl->getRangeDataLeaf(mnCurPos, aData))
613  return false;
614  }
615 
616  mnCurValue = aData.mnValue;
617  mnLastPos = aData.mnPos2;
618  }
619 
620  rVal = mnCurValue;
621  return true;
622 }
623 
625  mpImpl(new ScFlatUInt16SegmentsImpl(nMaxRow, nDefault))
626 {
627 }
628 
630  mpImpl(new ScFlatUInt16SegmentsImpl(*r.mpImpl))
631 {
632 }
633 
635 {
636 }
637 
638 void ScFlatUInt16RowSegments::setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue)
639 {
640  mpImpl->setValue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2), nValue);
641 }
642 
644 {
645  return mpImpl->getValue(static_cast<SCCOLROW>(nRow));
646 }
647 
649 {
650  return mpImpl->getSumValue(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
651 }
652 
654 {
655  ScFlatUInt16SegmentsImpl::RangeData aData;
656  if (!mpImpl->getRangeData(static_cast<SCCOLROW>(nRow), aData))
657  return false;
658 
659  rData.mnRow1 = aData.mnPos1;
660  rData.mnRow2 = aData.mnPos2;
661  rData.mnValue = aData.mnValue;
662  return true;
663 }
664 
666 {
667  mpImpl->removeSegment(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2));
668 }
669 
671 {
672  mpImpl->insertSegment(static_cast<SCCOLROW>(nRow), static_cast<SCCOLROW>(nSize), false/*bSkipStartBoundary*/);
673 }
674 
676 {
677  return mpImpl->findLastTrue(nValue);
678 }
679 
681 {
682  mpImpl->enableTreeSearch(bEnable);
683 }
684 
685 void ScFlatUInt16RowSegments::setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue, const std::function<bool(sal_uInt16)>& rPredicate)
686 {
687  mpImpl->setValueIf(static_cast<SCCOLROW>(nRow1), static_cast<SCCOLROW>(nRow2), nValue, rPredicate);
688 }
689 
691 {
692  mpImpl->makeReady();
693 }
694 
696 {
697  OString aOutput;
698  OString aSegment;
699  RangeData aRange;
700  SCROW nRow = 0;
701  while (getRangeData(nRow, aRange))
702  {
703  aSegment = OString::number(aRange.mnValue) + ":" +
704  OString::number(aRange.mnRow2) + " ";
705  aOutput += aSegment;
706  nRow = aRange.mnRow2 + 1;
707  }
708 
709  return aOutput;
710 }
711 
712 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
bool getFirst(RangeData &rRange)
bool getRangeDataLeaf(SCROW nRow, RangeData &rData)
static SC_DLLPUBLIC bool bThreadedGroupCalcInProgress
Calc's threaded group calculation is in progress.
Definition: global.hxx:804
sal_uInt32 getSumValue(SCROW nRow1, SCROW nRow2)
void removeSegment(SCROW nRow1, SCROW nRow2)
bool getValue(SCROW nPos, bool &rVal)
void insertSegment(SCROW nRow, SCROW nSize)
bool setFalse(SCROW nRow1, SCROW nRow2)
ScFlatBoolRowSegments(SCROW nMaxRow)
void removeSegment(SCCOL nCol1, SCCOL nCol2)
bool getNext(RangeData &rRange)
ScFlatUInt16RowSegments(SCROW nMaxRow, sal_uInt16 nDefault)
void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue, const std::function< bool(sal_uInt16)> &rPredicate)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
bool setTrue(SCROW nRow1, SCROW nRow2)
bool setFalse(SCCOL nCol1, SCCOL nCol2)
void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue)
constexpr OUStringLiteral aData
::std::unique_ptr< ScFlatUInt16SegmentsImpl > mpImpl
void insertSegment(SCCOL nCol, SCCOL nSize)
#define SAL_MAX_INT32
void enableTreeSearch(bool bEnable)
ForwardIterator(ScFlatBoolRowSegments &rSegs)
sal_Int16 SCCOL
Definition: types.hxx:21
ScFlatBoolSegmentsImpl(SCCOLROW nMax)
ScFlatBoolColSegments(SCCOL nMaxCol)
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
SCROW findLastTrue() const
ScFlatUInt16SegmentsImpl(SCCOLROW nMax, sal_uInt16 nDefault)
SCROW findLastTrue(sal_uInt16 nValue) const
sal_Int32 SCROW
Definition: types.hxx:17
T saturating_add(T a, T b)
::std::unique_ptr< ScFlatBoolSegmentsImpl > mpImpl
::std::unique_ptr< ScFlatBoolSegmentsImpl > mpImpl
Definition: segmenttree.hxx:85
bool getRangeData(SCROW nRow, RangeData &rData)
RangeIterator(ScFlatBoolRowSegments const &rSegs)
ValueType
#define SAL_WARN(area, stream)
sal_uInt16 getValue(SCROW nRow)
void insertSegment(SCROW nRow, SCROW nSize)
bool getRangeData(SCROW nRow, RangeData &rData) const
bool getRangeData(SCCOL nCol, RangeData &rData)
bool getValue(SCROW nPos, sal_uInt16 &rVal)
void removeSegment(SCROW nRow1, SCROW nRow2)
ForwardIterator(ScFlatUInt16RowSegments &rSegs)
bool setFalse(SCCOLROW nPos1, SCCOLROW nPos2)
bool setTrue(SCCOLROW nPos1, SCCOLROW nPos2)
bool setTrue(SCCOL nCol1, SCCOL nCol2)
const double mnValue