7 #ifndef XGBOOST_COMMON_ROW_SET_H_ 8 #define XGBOOST_COMMON_ROW_SET_H_ 25 const size_t*
end{
nullptr};
33 : begin(begin), end(end), node_id(node_id) {}
35 inline size_t Size()
const {
45 inline std::vector<Elem>::const_iterator
begin()
const {
46 return elem_of_each_node_.begin();
49 inline std::vector<Elem>::const_iterator
end()
const {
50 return elem_of_each_node_.end();
56 CHECK(e.
begin !=
nullptr)
57 <<
"access element that is not in the set";
62 elem_of_each_node_.clear();
66 CHECK_EQ(elem_of_each_node_.size(), 0U);
74 const size_t*
begin =
reinterpret_cast<size_t*
>(20);
76 elem_of_each_node_.emplace_back(
Elem(begin, end, 0));
82 elem_of_each_node_.emplace_back(
Elem(begin, end, 0));
86 const std::vector<Split>& row_split_tloc,
87 unsigned left_node_id,
88 unsigned right_node_id) {
90 const auto nthread =
static_cast<bst_omp_uint>(row_split_tloc.size());
91 CHECK(e.
begin !=
nullptr);
93 size_t*
begin = all_begin + (e.
begin - all_begin);
97 std::copy(row_split_tloc[tid].left.begin(), row_split_tloc[tid].left.end(), it);
98 it += row_split_tloc[tid].left.size();
100 size_t* split_pt = it;
102 std::copy(row_split_tloc[tid].right.begin(), row_split_tloc[tid].right.end(), it);
103 it += row_split_tloc[tid].right.size();
106 if (left_node_id >= elem_of_each_node_.size()) {
107 elem_of_each_node_.resize(left_node_id + 1,
Elem(
nullptr,
nullptr, -1));
109 if (right_node_id >= elem_of_each_node_.size()) {
110 elem_of_each_node_.resize(right_node_id + 1,
Elem(
nullptr,
nullptr, -1));
113 elem_of_each_node_[left_node_id] =
Elem(begin, split_pt, left_node_id);
114 elem_of_each_node_[right_node_id] =
Elem(split_pt, e.
end, right_node_id);
115 elem_of_each_node_[
node_id] =
Elem(
nullptr,
nullptr, -1);
123 std::vector<Elem> elem_of_each_node_;
129 #endif // XGBOOST_COMMON_ROW_SET_H_ collection of rowset
Definition: row_set.h:18
std::vector< Elem >::const_iterator begin() const
Definition: row_set.h:45
Elem(const size_t *begin, const size_t *end, int node_id)
Definition: row_set.h:30
The input data structure of xgboost.
dmlc::omp_uint bst_omp_uint
define unsigned int for openmp loop
Definition: base.h:246
void Init()
Definition: row_set.h:65
std::vector< Elem >::const_iterator end() const
Definition: row_set.h:49
void AddSplit(unsigned node_id, const std::vector< Split > &row_split_tloc, unsigned left_node_id, unsigned right_node_id)
Definition: row_set.h:85
int node_id
Definition: row_set.h:26
namespace of xgboost
Definition: base.h:102
data structure to store an instance set, a subset of rows (instances) associated with a particular no...
Definition: row_set.h:23
const size_t * begin
Definition: row_set.h:24
const Elem & operator[](unsigned node_id) const
return corresponding element set given the node_id
Definition: row_set.h:54
const size_t * end
Definition: row_set.h:25
std::vector< size_t > row_indices_
Definition: row_set.h:119
std::vector< size_t > left
Definition: row_set.h:41
std::vector< size_t > right
Definition: row_set.h:42
void Clear()
Definition: row_set.h:61
size_t Size() const
Definition: row_set.h:35