5 template<
typename ElementType,
typename NodeIndexType,
6 template<
typename,
typename...>
class NodeContainerType,
7 template<
typename,
typename...>
class IndexContainerType>
20 using node_ref_t = std::tuple<ElementType&, index_container_t&>;
23 using node_info_t = std::tuple<const ElementType&, const_ref_element_container_t>;
32 auto begin() {
return this->m_nodes.begin(); }
33 auto end() {
return this->m_nodes.end(); }
35 auto cbegin() {
return this->m_nodes.cbegin(); }
36 auto cend() {
return this->m_nodes.cend(); }
38 bool empty()
const {
return this->m_nodes.empty(); }
42 return tpf::element<node_container_t&>(m_nodes, node_index);
47 return tpf::element<const node_container_t&>(m_nodes, node_index);
56 auto indices = tpf::element<node_container_t&>(m_nodes, node_index);
58 for(
auto& idx: indices)
60 auto& value = tpf::element<element_container_t&>(m_values, idx);
61 elements.emplace_back(
std::ref(value));
70 auto indices = tpf::element<const node_container_t&>(m_nodes, node_index);
72 for(
auto& idx: indices)
74 auto& value = tpf::element<const element_container_t&>(m_values, idx);
75 elements.emplace_back(std::cref(value));
83 return tpf::element<element_container_t&>(m_values, node_index);
88 return tpf::element<const element_container_t&>(m_values, node_index);
94 auto indices = tpf::element<const node_container_t&>(m_nodes, node_index);
96 for(
auto& idx: indices)
98 auto& value = tpf::element<const element_container_t&>(m_values, idx);
99 elements.emplace_back(std::cref(value));
102 return {
node_value(node_index), std::move(elements) };
108 size_t size() {
return this->m_nodes.size(); }
110 template<
typename EleType,
typename Type,
typename... Types>
113 auto v = tpf::make_random_access_container<IndexContainerType>((NodeIndexType)std::forward<Type>(index0),
114 (NodeIndexType)std::forward<Types>(indices)...);
117 this->m_nodes.emplace_back(std::move(v));
118 this->m_values.emplace_back(std::forward<EleType>(value));
123 return node_ref_t{ tpf::element<element_container_t&>(this->m_values, node_index),
124 tpf::element<node_container_t&>(this->m_nodes, node_index) };
129 return const_node_ref_t{ tpf::element<const element_container_t&>(this->m_values, node_index),
130 tpf::element<const node_container_t&>(this->m_nodes, node_index) };
135 if(g.m_nodes.empty())
144 auto last_itr = g.m_nodes.cend();
152 for(
auto itr = g.m_nodes.cbegin(); itr != g.m_nodes.cend(); ++itr)
153 os << std::setw(3) << index <<
" - ("
154 << tpf::element<const element_container_t&>(g.m_values, index++)<<
") " << *itr <<
"\n";
162 template<
typename ElementType = int,
typename NodeIndexType = int,
163 template<
typename,
typename...>
class NodeContainerType = std::list,
164 template<
typename,
typename...>
class IndexContainerType = std::vector>
reference_wrapper< Type > ref(Type &val) noexcept
std::tuple< const ElementType &, const_ref_element_container_t > node_info_t
const element_container_t & values() const
NodeContainerType< std::reference_wrapper< element_t > > ref_element_container_t
decltype(auto) node_value(size_t node_index) const
auto adjacent_node_values(size_t node_index) const
std::tuple< const ElementType &, const index_container_t & > const_node_ref_t
decltype(auto) adjacency_node_list(size_t node_index)
decltype(auto) adjacency_node_list(size_t node_index) const
auto operator[](size_t node_index)
void emplace_back(EleType &&value, Type &&index0, Types &&... indices)
NodeContainerType< std::reference_wrapper< const element_t > > const_ref_element_container_t
NodeContainerType< index_container_t > node_container_t
auto operator[](size_t node_index) const
std::tuple< ElementType &, index_container_t & > node_ref_t
decltype(auto) node_value(size_t node_index)
friend tpf::sstream & operator<<(tpf::sstream &os, const graph &g)
auto adjacent_node_values(size_t node_index)
NodeContainerType< element_t > element_container_t
const node_container_t & node_lists() const
node_info_t node_info(size_t node_index) const
IndexContainerType< index_t > index_container_t
types::enable_if_container_type_t< ContainerType< EleType, Types... >, bool > sort_in_place(ContainerType< EleType, Types... > &container, sort_order order=sort_order::ascending, sort_method method=sort_method::size)
Includes subnamespace conversion.
Implements set operations.