Bump version to 6.4-15
[LibreOffice.git] / sc / inc / segmenttree.hxx
blob23a7ad78b389d7e0ffe3c2f19f6dc08613446b35
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]]
46 bool getValue(SCROW nPos, bool& rVal);
47 SCROW getLastPos() const { return mnLastPos;}
49 private:
50 ScFlatBoolRowSegments& mrSegs;
52 SCROW mnCurPos;
53 SCROW mnLastPos;
54 bool mbCurValue;
57 class RangeIterator
59 public:
60 explicit RangeIterator(ScFlatBoolRowSegments const & rSegs);
61 bool getFirst(RangeData& rRange);
62 bool getNext(RangeData& rRange);
63 private:
64 ScFlatBoolRowSegments const & mrSegs;
67 ScFlatBoolRowSegments();
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 OString dumpAsString();
82 private:
83 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
86 class ScFlatBoolColSegments
88 public:
89 struct RangeData
91 SCCOL mnCol1;
92 SCCOL mnCol2;
93 bool mbValue;
95 ScFlatBoolColSegments();
96 ScFlatBoolColSegments(const ScFlatBoolColSegments& r);
97 ~ScFlatBoolColSegments();
99 bool setTrue(SCCOL nCol1, SCCOL nCol2);
100 bool setFalse(SCCOL nCol1, SCCOL nCol2);
101 bool getRangeData(SCCOL nCol, RangeData& rData);
102 void removeSegment(SCCOL nCol1, SCCOL nCol2);
103 void insertSegment(SCCOL nCol, SCCOL nSize);
105 OString dumpAsString();
107 private:
108 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
111 class ScFlatUInt16SegmentsImpl;
113 class ScFlatUInt16RowSegments
115 public:
116 struct RangeData
118 SCROW mnRow1;
119 SCROW mnRow2;
120 sal_uInt16 mnValue;
123 class ForwardIterator
125 public:
126 explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs);
128 bool getValue(SCROW nPos, sal_uInt16& rVal);
129 SCROW getLastPos() const { return mnLastPos;}
131 private:
132 ScFlatUInt16RowSegments& mrSegs;
134 SCROW mnCurPos;
135 SCROW mnLastPos;
136 sal_uInt16 mnCurValue;
139 ScFlatUInt16RowSegments(sal_uInt16 nDefault);
140 ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r);
141 ~ScFlatUInt16RowSegments();
143 void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue);
144 void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue, const std::function<bool(sal_uInt16)>& rPredicate);
145 sal_uInt16 getValue(SCROW nRow);
146 sal_uInt32 getSumValue(SCROW nRow1, SCROW nRow2);
147 bool getRangeData(SCROW nRow, RangeData& rData);
148 void removeSegment(SCROW nRow1, SCROW nRow2);
149 void insertSegment(SCROW nRow, SCROW nSize);
151 SCROW findLastTrue(sal_uInt16 nValue) const;
153 void enableTreeSearch(bool bEnable);
155 OString dumpAsString();
157 private:
158 ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl;
161 #endif
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */