Skip to content

Commit 18ba8f7

Browse files
committed
[c++] mark a few more read-only methods const
1 parent f72ac26 commit 18ba8f7

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

include/LightGBM/feature_group.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ class FeatureGroup {
566566
}
567567
}
568568

569-
uint32_t feature_max_bin(const int sub_feature_index) {
569+
uint32_t feature_max_bin(const int sub_feature_index) const {
570570
if (!is_multi_val_) {
571571
return bin_offsets_[sub_feature_index + 1] - 1;
572572
} else {
@@ -575,7 +575,7 @@ class FeatureGroup {
575575
}
576576
}
577577

578-
uint32_t feature_min_bin(const int sub_feature_index) {
578+
uint32_t feature_min_bin(const int sub_feature_index) const {
579579
if (!is_multi_val_) {
580580
return bin_offsets_[sub_feature_index];
581581
} else {

include/LightGBM/train_share_states.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MultiValBinWrapper {
2323
MultiValBinWrapper(MultiValBin* bin, data_size_t num_data,
2424
const std::vector<int>& feature_groups_contained, const int num_grad_quant_bins);
2525

26-
bool IsSparse() {
26+
bool const IsSparse() {
2727
if (multi_val_bin_ != nullptr) {
2828
return multi_val_bin_->IsSparse();
2929
}
@@ -277,15 +277,15 @@ struct TrainingShareStates {
277277
multi_val_bin_wrapper_.reset(nullptr);
278278
}
279279

280-
int num_hist_total_bin() { return num_hist_total_bin_; }
280+
int num_hist_total_bin() const { return num_hist_total_bin_; }
281281

282282
const std::vector<uint32_t>& feature_hist_offsets() const { return feature_hist_offsets_; }
283283

284284
#ifdef USE_CUDA
285285
const std::vector<uint32_t>& column_hist_offsets() const { return column_hist_offsets_; }
286286
#endif // USE_CUDA
287287

288-
bool IsSparseRowwise() {
288+
bool IsSparseRowwise() const {
289289
return (multi_val_bin_wrapper_ != nullptr && multi_val_bin_wrapper_->IsSparse());
290290
}
291291

include/LightGBM/utils/byte_buffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ struct ByteBuffer final : public BinaryWriter {
4242
buffer_.reserve(capacity);
4343
}
4444

45-
LIGHTGBM_EXPORT size_t GetSize() {
45+
LIGHTGBM_EXPORT size_t GetSize() const {
4646
return buffer_.size();
4747
}
4848

49-
LIGHTGBM_EXPORT char GetAt(size_t index) {
49+
LIGHTGBM_EXPORT char GetAt(size_t index) const {
5050
return buffer_.at(index);
5151
}
5252

53-
LIGHTGBM_EXPORT char* Data() {
53+
LIGHTGBM_EXPORT char* Data() const {
5454
return buffer_.data();
5555
}
5656

src/treelearner/feature_histogram.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ class FeatureHistogram {
702702
/*!
703703
* \brief True if this histogram can be splitted
704704
*/
705-
bool is_splittable() { return is_splittable_; }
705+
bool is_splittable() const { return is_splittable_; }
706706

707707
/*!
708708
* \brief Set splittable to this histogram

src/treelearner/monotone_constraints.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ struct AdvancedFeatureConstraints : FeatureConstraint {
306306
max_constraints.UpdateMax(new_max);
307307
}
308308

309-
bool FeatureMaxConstraintsToBeUpdated() {
309+
bool FeatureMaxConstraintsToBeUpdated() const {
310310
return max_constraints_to_be_recomputed;
311311
}
312312

313-
bool FeatureMinConstraintsToBeUpdated() {
313+
bool FeatureMinConstraintsToBeUpdated() const {
314314
return min_constraints_to_be_recomputed;
315315
}
316316

0 commit comments

Comments
 (0)