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 #ifndef INCLUDED_SC_INC_SEGMENTTREE_HXX
21 #define INCLUDED_SC_INC_SEGMENTTREE_HXX
22 
23 #include "types.hxx"
24 #include <rtl/string.hxx>
25 
26 #include <memory>
27 
29 
31 {
32 public:
33  struct RangeData
34  {
37  bool mbValue;
38  };
39 
41  {
42  public:
43  explicit ForwardIterator(ScFlatBoolRowSegments& rSegs);
44 
45  [[nodiscard]]
46  bool getValue(SCROW nPos, bool& rVal);
47  SCROW getLastPos() const { return mnLastPos;}
48 
49  private:
51 
54  bool mbCurValue;
55  };
56 
58  {
59  public:
60  explicit RangeIterator(ScFlatBoolRowSegments const & rSegs);
61  bool getFirst(RangeData& rRange);
62  bool getNext(RangeData& rRange);
63  private:
65  };
66 
70 
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);
77 
78  SCROW findLastTrue() const;
79 
80  OString dumpAsString();
81 
82 private:
83  ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
84 };
85 
87 {
88 public:
89  struct RangeData
90  {
93  bool mbValue;
94  };
98 
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);
104 
105  OString dumpAsString();
106 
107 private:
108  ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl;
109 };
110 
112 
114 {
115 public:
116  struct RangeData
117  {
120  sal_uInt16 mnValue;
121  };
122 
124  {
125  public:
126  explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs);
127 
128  bool getValue(SCROW nPos, sal_uInt16& rVal);
129  SCROW getLastPos() const { return mnLastPos;}
130 
131  private:
133 
136  sal_uInt16 mnCurValue;
137  };
138 
139  ScFlatUInt16RowSegments(SCROW nMaxRow, sal_uInt16 nDefault);
142 
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);
150 
151  SCROW findLastTrue(sal_uInt16 nValue) const;
152 
153  void enableTreeSearch(bool bEnable);
154 
155  OString dumpAsString();
156 
157 private:
158  ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl;
159 };
160 
161 #endif
162 
163 /* 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:22
ScFlatBoolColSegments(SCCOL nMaxCol)
SCROW findLastTrue() const
SCROW findLastTrue(sal_uInt16 nValue) const
sal_Int32 SCROW
Definition: types.hxx:18
::std::unique_ptr< ScFlatBoolSegmentsImpl > mpImpl
::std::unique_ptr< ScFlatBoolSegmentsImpl > mpImpl
Definition: segmenttree.hxx:83
bool getRangeData(SCROW nRow, RangeData &rData)
ScFlatBoolRowSegments const & mrSegs
Definition: segmenttree.hxx:64
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)