LibreOffice Module sc (master)  1
segmenttree.hxx
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 #pragma once
21 
22 #include "types.hxx"
23 #include <rtl/string.hxx>
24 
25 #include <memory>
26 
28 
30 {
31 public:
32  struct RangeData
33  {
36  bool mbValue;
37  };
38 
40  {
41  public:
42  explicit ForwardIterator(ScFlatBoolRowSegments& rSegs);
43 
44  [[nodiscard]] bool getValue(SCROW nPos, bool& rVal);
45  SCROW getLastPos() const { return mnLastPos; }
46 
47  private:
49 
52  bool mbCurValue;
53  };
54 
56  {
57  public:
58  explicit RangeIterator(ScFlatBoolRowSegments const& rSegs);
59  bool getFirst(RangeData& rRange);
60  bool getNext(RangeData& rRange);
61 
62  private:
64  };
65 
69 
70  bool setTrue(SCROW nRow1, SCROW nRow2);
71  bool setFalse(SCROW nRow1, SCROW nRow2);
72  bool getRangeData(SCROW nRow, RangeData& rData) const;
73  bool getRangeDataLeaf(SCROW nRow, RangeData& rData);
74  void removeSegment(SCROW nRow1, SCROW nRow2);
75  void insertSegment(SCROW nRow, SCROW nSize);
76 
77  SCROW findLastTrue() const;
78 
79  // Builds internal data (so that it doesn't build them while used in threads).
80  void makeReady();
81 
82  OString dumpAsString();
83 
84 private:
85  ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
86 };
87 
89 {
90 public:
91  struct RangeData
92  {
95  bool mbValue;
96  };
100 
101  bool setTrue(SCCOL nCol1, SCCOL nCol2);
102  bool setFalse(SCCOL nCol1, SCCOL nCol2);
103  bool getRangeData(SCCOL nCol, RangeData& rData);
104  void removeSegment(SCCOL nCol1, SCCOL nCol2);
105  void insertSegment(SCCOL nCol, SCCOL nSize);
106 
107  // Builds internal data (so that it doesn't build them while used in threads).
108  void makeReady();
109 
110  OString dumpAsString();
111 
112 private:
113  ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
114 };
115 
117 
119 {
120 public:
121  struct RangeData
122  {
125  sal_uInt16 mnValue;
126  };
127 
129  {
130  public:
131  explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs);
132 
133  bool getValue(SCROW nPos, sal_uInt16& rVal);
134  SCROW getLastPos() const { return mnLastPos; }
135 
136  private:
138 
141  sal_uInt16 mnCurValue;
142  };
143 
144  ScFlatUInt16RowSegments(SCROW nMaxRow, sal_uInt16 nDefault);
147 
148  void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue);
149  void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue,
150  const std::function<bool(sal_uInt16)>& rPredicate);
151  sal_uInt16 getValue(SCROW nRow);
152  sal_uInt32 getSumValue(SCROW nRow1, SCROW nRow2);
153  bool getRangeData(SCROW nRow, RangeData& rData);
154  void removeSegment(SCROW nRow1, SCROW nRow2);
155  void insertSegment(SCROW nRow, SCROW nSize);
156 
157  SCROW findLastTrue(sal_uInt16 nValue) const;
158 
159  void enableTreeSearch(bool bEnable);
160 
161  // Builds internal data (so that it doesn't build them while used in threads).
162  void makeReady();
163 
164  OString dumpAsString();
165 
166 private:
167  ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl;
168 };
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool getFirst(RangeData &rRange)
bool getRangeDataLeaf(SCROW nRow, RangeData &rData)
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)
bool setTrue(SCROW nRow1, SCROW nRow2)
bool setFalse(SCCOL nCol1, SCCOL nCol2)
void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue)
::std::unique_ptr< ScFlatUInt16SegmentsImpl > mpImpl
void insertSegment(SCCOL nCol, SCCOL nSize)
void enableTreeSearch(bool bEnable)
ForwardIterator(ScFlatBoolRowSegments &rSegs)
sal_Int16 SCCOL
Definition: types.hxx:21
ScFlatBoolColSegments(SCCOL nMaxCol)
SCROW findLastTrue() const
SCROW findLastTrue(sal_uInt16 nValue) const
sal_Int32 SCROW
Definition: types.hxx:17
::std::unique_ptr< ScFlatBoolSegmentsImpl > mpImpl
::std::unique_ptr< ScFlatBoolSegmentsImpl > mpImpl
Definition: segmenttree.hxx:85
bool getRangeData(SCROW nRow, RangeData &rData)
ScFlatBoolRowSegments const & mrSegs
Definition: segmenttree.hxx:63
RangeIterator(ScFlatBoolRowSegments const &rSegs)
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)
sal_uInt16 nPos
bool setTrue(SCCOL nCol1, SCCOL nCol2)