\doxysection{segmented\+\_\+array.\+hpp}
\hypertarget{segmented__array_8hpp_source}{}\label{segmented__array_8hpp_source}\index{ginkgo/core/base/segmented\_array.hpp@{ginkgo/core/base/segmented\_array.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ SPDX-\/FileCopyrightText:\ 2017\ -\/\ 2025\ The\ Ginkgo\ authors}}
\DoxyCodeLine{00002\ \textcolor{comment}{//}}
\DoxyCodeLine{00003\ \textcolor{comment}{//\ SPDX-\/License-\/Identifier:\ BSD-\/3-\/Clause}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#ifndef\ GKO\_PUBLIC\_CORE\_BASE\_SEGMENTED\_ARRAY\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_BASE\_SEGMENTED\_ARRAY\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <numeric>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/config.hpp>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/array.hpp>}}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00026\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00027\ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\ \{}
\DoxyCodeLine{00033\ \ \ \ \ \textcolor{keyword}{explicit}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}(std::shared\_ptr<const\ Executor>\ exec);}
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keyword}{static}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_ad6192b7cc6d0722090172cf856a44ad0}{create\_from\_sizes}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{gko::array<int64>}}\&\ sizes);}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00049\ \ \ \ \ \textcolor{keyword}{static}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a5d97107168d4862706196522b7811a72}{create\_from\_sizes}}(\doxymbox{\hyperlink{classgko_1_1array}{gko::array<T>}}\ buffer,}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{gko::array<int64>}}\&\ sizes);}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00058\ \ \ \ \ \textcolor{keyword}{static}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_af4e6803142d06709ad3ab8e935c40ee7}{create\_from\_offsets}}(\doxymbox{\hyperlink{classgko_1_1array}{gko::array<int64>}}\ offsets);}
\DoxyCodeLine{00059\ }
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keyword}{static}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a421743af79c9b15903988ffa38d9f5f0}{create\_from\_offsets}}(\doxymbox{\hyperlink{classgko_1_1array}{gko::array<T>}}\ buffer,}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1array}{gko::array<int64>}}\ offsets);}
\DoxyCodeLine{00070\ }
\DoxyCodeLine{00077\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a392c0c6a7ec9d2b03d2a3cf81a8d22db}{segmented\_array}}(std::shared\_ptr<const\ Executor>\ exec,}
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\ other);}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00086\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a78639e5673e0614b2dc510eb26838706}{segmented\_array}}(std::shared\_ptr<const\ Executor>\ exec,}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\&\ other);}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\ other);}
\DoxyCodeLine{00090\ }
\DoxyCodeLine{00091\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}(\doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\&\ other)\ \textcolor{keyword}{noexcept}(\textcolor{keyword}{false});}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\ operator=(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\ other);}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00095\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\ operator=(\doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}\&\&)\ noexcept(false);}
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00102\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a8e919761b20e50b3129374496fe6c787}{get\_size}}()\ const;}
\DoxyCodeLine{00103\ }
\DoxyCodeLine{00109\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a67bd3d0c920bdaa58a2df398df947170}{get\_segment\_count}}()\ const;}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00116\ \ \ \ \ T*\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a8b04a39c9bb042442fecf0e16842f7f6}{get\_flat\_data}}();}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00123\ \ \ \ \ const\ T*\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a1f9b52d6f937feec89fe6dd809b02460}{get\_const\_flat\_data}}()\ const;}
\DoxyCodeLine{00124\ }
\DoxyCodeLine{00130\ \ \ \ \ const\ \doxymbox{\hyperlink{namespacegko}{gko}}::\doxymbox{\hyperlink{classgko_1_1array}{array}}<\doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}>\&\ \doxymbox{\hyperlink{structgko_1_1segmented__array_ae3259b2190ca3226d49dd3ac204a2bac}{get\_offsets}}()\ const;}
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00137\ \ \ \ \ \doxymbox{\hyperlink{namespacestd}{std}}::shared\_ptr<const\ \doxymbox{\hyperlink{classgko_1_1Executor}{Executor}}>\ \doxymbox{\hyperlink{structgko_1_1segmented__array_ad0efe2e79dde2117d3e632a90147e932}{get\_executor}}()\ const;}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ private:}
\DoxyCodeLine{00140\ \ \ \ \ \doxymbox{\hyperlink{namespacegko}{gko}}::\doxymbox{\hyperlink{classgko_1_1array}{array}}<T>\ buffer\_;}
\DoxyCodeLine{00141\ \ \ \ \ \doxymbox{\hyperlink{namespacegko}{gko}}::\doxymbox{\hyperlink{classgko_1_1array}{array}}<\doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}>\ offsets\_;}
\DoxyCodeLine{00142\ \};}
\DoxyCodeLine{00143\ }
\DoxyCodeLine{00144\ }
\DoxyCodeLine{00145\ namespace\ detail\ \{}
\DoxyCodeLine{00146\ }
\DoxyCodeLine{00147\ }
\DoxyCodeLine{00148\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00149\ \textcolor{keyword}{struct\ }temporary\_clone\_helper<\doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}<T>>\ \{}
\DoxyCodeLine{00150\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<segmented\_array<T>>\ create(}
\DoxyCodeLine{00151\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec,\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array<T>}}*\ ptr,}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ copy\_data)}
\DoxyCodeLine{00153\ \ \ \ \ \{}
\DoxyCodeLine{00154\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (copy\_data)\ \{}
\DoxyCodeLine{00155\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ std::make\_unique<segmented\_array<T>>(std::move(exec),\ *ptr);}
\DoxyCodeLine{00156\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00157\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ std::unique\_ptr<segmented\_array<T>>(}
\DoxyCodeLine{00158\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{new}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array<T>}}(\doxymbox{\hyperlink{structgko_1_1segmented__array_af4e6803142d06709ad3ab8e935c40ee7}{segmented\_array<T>::create\_from\_offsets}}(}
\DoxyCodeLine{00159\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1array}{array<int64>}}(std::move(exec),\ ptr-\/>\doxymbox{\hyperlink{structgko_1_1segmented__array_ae3259b2190ca3226d49dd3ac204a2bac}{get\_offsets}}()))));}
\DoxyCodeLine{00160\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00161\ \ \ \ \ \}}
\DoxyCodeLine{00162\ \};}
\DoxyCodeLine{00163\ }
\DoxyCodeLine{00164\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00165\ \textcolor{keyword}{struct\ }temporary\_clone\_helper<const\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}<T>>\ \{}
\DoxyCodeLine{00166\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<const\ segmented\_array<T>>\ create(}
\DoxyCodeLine{00167\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array<T>}}*\ ptr,}
\DoxyCodeLine{00168\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool})}
\DoxyCodeLine{00169\ \ \ \ \ \{}
\DoxyCodeLine{00170\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ std::make\_unique<segmented\_array<T>>(std::move(exec),\ *ptr);}
\DoxyCodeLine{00171\ \ \ \ \ \}}
\DoxyCodeLine{00172\ \};}
\DoxyCodeLine{00173\ }
\DoxyCodeLine{00174\ }
\DoxyCodeLine{00175\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00176\ \textcolor{keyword}{class\ }copy\_back\_deleter<\doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array}}<T>>}
\DoxyCodeLine{00177\ \ \ \ \ :\ \textcolor{keyword}{public}\ copy\_back\_deleter\_from\_assignment<segmented\_array<T>>\ \{}
\DoxyCodeLine{00178\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{keyword}{using\ }copy\_back\_deleter\_from\_assignment<}
\DoxyCodeLine{00180\ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array_a550323a47257c9af8fdc96bc5a72b950}{segmented\_array<T>}}>::copy\_back\_deleter\_from\_assignment;}
\DoxyCodeLine{00181\ \};}
\DoxyCodeLine{00182\ }
\DoxyCodeLine{00183\ }
\DoxyCodeLine{00184\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00185\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00186\ }
\DoxyCodeLine{00187\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_BASE\_SEGMENTED\_ARRAY\_HPP\_}}

\end{DoxyCode}
