nss: upgrade to release 3.73
[LibreOffice.git] / sc / inc / segmenttree.hxx
blob7e25d232a03f3a78efbccf14a3857ae984fab76d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_SEGMENTTREE_HXX
21 #define INCLUDED_SC_INC_SEGMENTTREE_HXX
23 #include "types.hxx"
24 #include <rtl/string.hxx>
26 #include <memory>
28 class ScFlatBoolSegmentsImpl;
30 class ScFlatBoolRowSegments
32 public:
33 struct RangeData
35 SCROW mnRow1;
36 SCROW mnRow2;
37 bool mbValue;
40 class ForwardIterator
42 public:
43 explicit ForwardIterator(ScFlatBoolRowSegments& rSegs);
45 [[nodiscard]] bool getValue(SCROW nPos, bool& rVal);
46 SCROW getLastPos() const { return mnLastPos; }
48 private:
49 ScFlatBoolRowSegments& mrSegs;
51 SCROW mnCurPos;
52 SCROW mnLastPos;
53 bool mbCurValue;
56 class RangeIterator
58 public:
59 explicit RangeIterator(ScFlatBoolRowSegments const& rSegs);
60 bool getFirst(RangeData& rRange);
61 bool getNext(RangeData& rRange);
63 private:
64 ScFlatBoolRowSegments const& mrSegs;
67 ScFlatBoolRowSegments(SCROW nMaxRow);
68 ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r);
69 ~ScFlatBoolRowSegments();
71 bool setTrue(SCROW nRow1, SCROW nRow2);
72 bool setFalse(SCROW nRow1, SCROW nRow2);
73 bool getRangeData(SCROW nRow, RangeData& rData) const;
74 bool getRangeDataLeaf(SCROW nRow, RangeData& rData);
75 void removeSegment(SCROW nRow1, SCROW nRow2);
76 void insertSegment(SCROW nRow, SCROW nSize);
78 SCROW findLastTrue() const;
80 // Builds internal data (so that it doesn't build them while used in threads).
81 void makeReady();
83 OString dumpAsString();
85 private:
86 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
89 class ScFlatBoolColSegments
91 public:
92 struct RangeData
94 SCCOL mnCol1;
95 SCCOL mnCol2;
96 bool mbValue;
98 ScFlatBoolColSegments(SCCOL nMaxCol);
99 ScFlatBoolColSegments(const ScFlatBoolColSegments& r);
100 ~ScFlatBoolColSegments();
102 bool setTrue(SCCOL nCol1, SCCOL nCol2);
103 bool setFalse(SCCOL nCol1, SCCOL nCol2);
104 bool getRangeData(SCCOL nCol, RangeData& rData);
105 void removeSegment(SCCOL nCol1, SCCOL nCol2);
106 void insertSegment(SCCOL nCol, SCCOL nSize);
108 // Builds internal data (so that it doesn't build them while used in threads).
109 void makeReady();
111 OString dumpAsString();
113 private:
114 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
117 class ScFlatUInt16SegmentsImpl;
119 class ScFlatUInt16RowSegments
121 public:
122 struct RangeData
124 SCROW mnRow1;
125 SCROW mnRow2;
126 sal_uInt16 mnValue;
129 class ForwardIterator
131 public:
132 explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs);
134 bool getValue(SCROW nPos, sal_uInt16& rVal);
135 SCROW getLastPos() const { return mnLastPos; }
137 private:
138 ScFlatUInt16RowSegments& mrSegs;
140 SCROW mnCurPos;
141 SCROW mnLastPos;
142 sal_uInt16 mnCurValue;
145 ScFlatUInt16RowSegments(SCROW nMaxRow, sal_uInt16 nDefault);
146 ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r);
147 ~ScFlatUInt16RowSegments();
149 void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue);
150 void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue,
151 const std::function<bool(sal_uInt16)>& rPredicate);
152 sal_uInt16 getValue(SCROW nRow);
153 sal_uInt32 getSumValue(SCROW nRow1, SCROW nRow2);
154 bool getRangeData(SCROW nRow, RangeData& rData);
155 void removeSegment(SCROW nRow1, SCROW nRow2);
156 void insertSegment(SCROW nRow, SCROW nSize);
158 SCROW findLastTrue(sal_uInt16 nValue) const;
160 void enableTreeSearch(bool bEnable);
162 // Builds internal data (so that it doesn't build them while used in threads).
163 void makeReady();
165 OString dumpAsString();
167 private:
168 ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl;
171 #endif
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */