.. _program_listing_file_src_sparsebase_format_array.h: Program Listing for File array.h ================================ |exhale_lsh| :ref:`Return to documentation for file ` (``src/sparsebase/format/array.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "sparsebase/config.h" #include "sparsebase/context/cpu_context.h" #include "sparsebase/format/format_order_one.h" #include "sparsebase/utils/exception.h" #include "sparsebase/utils/utils.h" #ifndef SPARSEBASE_PROJECT_ARRAY_H #define SPARSEBASE_PROJECT_ARRAY_H namespace sparsebase::format { template class Array : public utils::IdentifiableImplementation, FormatOrderOne> { public: Array(DimensionType nnz, ValueType *row_ptr, Ownership own = kNotOwned); Array(const Array &); Array(Array &&); Array &operator=(const Array &); Format *Clone() const override; virtual ~Array(); ValueType *get_vals() const; ValueType *release_vals(); void set_vals(ValueType *, Ownership own = kNotOwned); virtual bool ValsIsOwned(); protected: std::unique_ptr> vals_; }; template template struct FormatOrderOne::TypeConverter { format::Array *operator()(FormatOrderOne *source, bool is_move_conversion) { auto arr = source->template As(); auto num_nnz = arr->get_num_nnz(); ToValueType *new_vals; if (!is_move_conversion || !std::is_same_v) { new_vals = utils::ConvertArrayType(arr->get_vals(), num_nnz); } else { if constexpr (std::is_same_v) { new_vals = arr->release_vals(); } } return new Array(num_nnz, new_vals, kOwned); } }; } // namespace sparsebase::format #ifdef _HEADER_ONLY #include "array.cc" #endif #endif // SPARSEBASE_PROJECT_ARRAY_H