Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sc / inc / segmenttree.hxx
blob53eec168a72210ca38045eb454e6fa8db4359df3
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 "address.hxx"
25 #include <memory>
27 class ScFlatBoolSegmentsImpl;
29 class ScFlatBoolRowSegments
31 public:
32 struct RangeData
34 SCROW mnRow1;
35 SCROW mnRow2;
36 bool mbValue;
39 class ForwardIterator
41 public:
42 explicit ForwardIterator(ScFlatBoolRowSegments& rSegs);
44 SAL_WARN_UNUSED_RESULT
45 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& rSegs);
60 bool getFirst(RangeData& rRange);
61 bool getNext(RangeData& rRange);
62 private:
63 ScFlatBoolRowSegments& mrSegs;
66 ScFlatBoolRowSegments();
67 ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r);
68 ~ScFlatBoolRowSegments();
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);
77 SCROW findLastTrue() const;
79 private:
80 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
83 class ScFlatBoolColSegments
85 public:
86 struct RangeData
88 SCCOL mnCol1;
89 SCCOL mnCol2;
90 bool mbValue;
92 ScFlatBoolColSegments();
93 ScFlatBoolColSegments(const ScFlatBoolColSegments& r);
94 ~ScFlatBoolColSegments();
96 bool setTrue(SCCOL nCol1, SCCOL nCol2);
97 bool setFalse(SCCOL nCol1, SCCOL nCol2);
98 bool getRangeData(SCCOL nCol, RangeData& rData);
99 void removeSegment(SCCOL nCol1, SCCOL nCol2);
100 void insertSegment(SCCOL nCol, SCCOL nSize);
102 private:
103 ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
106 class ScFlatUInt16SegmentsImpl;
108 class ScFlatUInt16RowSegments
110 public:
111 struct RangeData
113 SCROW mnRow1;
114 SCROW mnRow2;
115 sal_uInt16 mnValue;
118 class ForwardIterator
120 public:
121 explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs);
123 bool getValue(SCROW nPos, sal_uInt16& rVal);
124 SCROW getLastPos() const { return mnLastPos;}
126 private:
127 ScFlatUInt16RowSegments& mrSegs;
129 SCROW mnCurPos;
130 SCROW mnLastPos;
131 sal_uInt16 mnCurValue;
134 ScFlatUInt16RowSegments(sal_uInt16 nDefault);
135 ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r);
136 ~ScFlatUInt16RowSegments();
138 void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue);
139 void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue, const std::function<bool(sal_uInt16)>& rPredicate);
140 sal_uInt16 getValue(SCROW nRow);
141 sal_uInt32 getSumValue(SCROW nRow1, SCROW nRow2);
142 bool getRangeData(SCROW nRow, RangeData& rData);
143 void removeSegment(SCROW nRow1, SCROW nRow2);
144 void insertSegment(SCROW nRow, SCROW nSize);
146 SCROW findLastTrue(sal_uInt16 nValue) const;
148 void enableTreeSearch(bool bEnable);
150 private:
151 ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl;
154 #endif
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */