Skip to content

Commit 62ace3d

Browse files
author
Aperjump
committed
Add documentation for constructors in data_frame
1 parent 77075c3 commit 62ace3d

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

include/boost/numeric/ublas/data_frame.hpp

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717
namespace boost { namespace numeric { namespace ublas {
1818
template<class... Types>
1919
class data_frame;
20+
/** @brief @code data_frame_type_builder @endcode is used to provide a more convenient type declaration
21+
* @code
22+
* using type_collection = type_list<int, double, std::string>::original_types;
23+
* data_frame_type_builder type_builder = {type_collection{}};
24+
* using data_frame_type = decltype(type_builder)::data_frame_type;
25+
* data_frame_type* df3 = make_from_tuples({ {1, 3.3, "hello"s},
26+
* {2, 2.2, "world"s},
27+
* {3, 1.1, "github"s} },
28+
* {"int_vec", "double_vec", "str_vec"},
29+
* type_collection{});
30+
* @endcode
31+
*
32+
* @tparam TypeLists a set of potential types, used as @code TypeLists<Types...> @endcode
33+
*
34+
* @tparam Types... a typelists containing concrete types in @code TypeLists<Types...> @endcode
35+
*/
2036
template<typename... Types>
2137
struct data_frame_type_builder {
2238
template<template<class...> class TypeLists, class... InnerTypes>
@@ -30,11 +46,37 @@ auto for_each(const std::tuple<Ts...>& t, const data_frame<Types...>* df,
3046
const std::vector<std::string>& names, size_t pos, std::index_sequence<Is...>) {
3147
return std::make_tuple(df->data_frame<Types...>::template get_c<Ts>(names[Is], pos)...);
3248
}
49+
/** @brief used to iterate each value in @code std::tuple @endcode
50+
*
51+
* @tparam Ts... types
52+
*
53+
* @tparam Types... a typelists containing concrete types in @code TypeLists<Types...> @endcode
54+
*
55+
* @param t one tuple used for deduct types
56+
*
57+
* @param df the @code data_frame @endcode operating on
58+
*
59+
* @param names the corresponding column name for each type in Types...
60+
*
61+
* @param pos the row index for df
62+
*/
3363
template<typename... Types, typename... Ts>
3464
auto for_each_in_tuple(const std::tuple<Ts...>& t, const data_frame<Types...>* df,
3565
const std::vector<std::string>& names, size_t pos) {
3666
return for_each(t, df, names, pos, std::index_sequence_for<Ts...>{});
3767
}
68+
/** @brief create a new @code data_frame @endcode from a vector of tuples
69+
*
70+
* @tparam TypeLists... a container for types
71+
*
72+
* @tparam InnerTypes... a typelists containing concrete types in @code TypeLists<Types...> @endcode
73+
*
74+
* @param t a vector of tuples with InnerTypes...
75+
*
76+
* @param names the corresponding column name for each type in InnerTypes...
77+
*
78+
* @param TypeLists<InnerTypes...> used for type deduction
79+
*/
3880
template<template<class...> class TypeLists, class... InnerTypes>
3981
auto make_from_tuples(const std::vector<std::tuple<InnerTypes...>>& t, const std::vector<std::string>& names,
4082
TypeLists<InnerTypes...>) {
@@ -50,17 +92,37 @@ auto make_from_tuples(const std::vector<std::tuple<InnerTypes...>>& t, const std
5092
template<class... Types>
5193
class data_frame_view;
5294

95+
/** @brief data_frame represents a collection of data_frame_col, and it's designed as a heterogenous container.
96+
* each data_frame_col can represent only one type
97+
*
98+
* @tparam Types... represent a non-repeated types from all data_frame_col
99+
*/
53100
template<class... Types>
54101
class data_frame {
55102
public:
56103
using data_frame_type = data_frame<Types...>;
57104
using store_t = std::list<data_frame_col>;
58105
using name_map_t = std::unordered_map<std::string, typename std::list<data_frame_col>::iterator>;
59106
using type_map_t = std::unordered_map<std::string, std::string>;
60-
// InnerTypes must be unique
107+
/** @brief Build an empty data_frame
108+
*
109+
* @note current column is empty
110+
*/
61111
data_frame(): cur_rows(-1) { }
112+
/** @brief Build an empty data_frame
113+
*
114+
* @tparam TypeLists a set of potential types, used as @code TypeLists<InnerTypes...> @endcode
115+
*
116+
* @tparam InnerTypes... a typelists containing concrete types in @code TypeLists<InnerTypes...> @endcode
117+
*/
62118
template<template<class...> class TypeLists, class... InnerTypes>
63119
data_frame(TypeLists<InnerTypes...>): cur_rows(-1) { }
120+
/** @brief Build an empty data_frame
121+
*
122+
* @tparam TypeLists a set of potential types, used as @code TypeLists<InnerTypes...> @endcode
123+
*
124+
* @tparam InnerTypes... a typelists containing concrete types in @code TypeLists<InnerTypes...> @endcode
125+
*/
64126
template<template<class...> class TypeLists, class... InnerTypes>
65127
data_frame(size_t rows, TypeLists<InnerTypes...>): cur_rows(rows) { }
66128
template<typename T>

0 commit comments

Comments
 (0)