From 86618955b716cc5947f775a74e6beb3b475948ec Mon Sep 17 00:00:00 2001 From: fis Date: Tue, 14 Dec 2021 09:30:24 +0800 Subject: [PATCH] Rename. --- cpp/include/raft/common/span.hpp | 68 ++++++++++++++++---------------- cpp/test/common/test_span.hpp | 44 ++++++++++----------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cpp/include/raft/common/span.hpp b/cpp/include/raft/common/span.hpp index c53d2a3a97..587fb4ea0e 100644 --- a/cpp/include/raft/common/span.hpp +++ b/cpp/include/raft/common/span.hpp @@ -29,7 +29,7 @@ namespace raft::common { constexpr std::size_t dynamic_extent = std::numeric_limits::max(); template -class Span; +class span_t; namespace detail { /*! @@ -72,7 +72,7 @@ struct is_span_oracle_t : std::false_type { }; template -struct is_span_oracle_t> : std::true_type { +struct is_span_oracle_t> : std::true_type { }; template @@ -99,7 +99,7 @@ __host__ __device__ constexpr auto lexicographical_compare(InputIt1 first1, * most of the methods have bound check on debug build. */ template -class Span { +class span_t { public: using element_type = T; using value_type = typename std::remove_cv::type; @@ -116,21 +116,21 @@ class Span { using const_reverse_iterator = thrust::reverse_iterator; // constructors - constexpr Span() noexcept = default; + constexpr span_t() noexcept = default; - constexpr Span(pointer _ptr, size_type _count) noexcept : size_(_count), data_(_ptr) + constexpr span_t(pointer _ptr, size_type _count) noexcept : size_(_count), data_(_ptr) { assert(!(Extent != dynamic_extent && _count != Extent)); assert(_ptr || _count == 0); } - constexpr Span(pointer _first, pointer _last) noexcept : size_(_last - _first), data_(_first) + constexpr span_t(pointer _first, pointer _last) noexcept : size_(_last - _first), data_(_first) { assert(data_ || size_ == 0); } template - constexpr Span(element_type (&arr)[N]) noexcept : size_(N), data_(&arr[0]) + constexpr span_t(element_type (&arr)[N]) noexcept : size_(N), data_(&arr[0]) { } @@ -139,14 +139,14 @@ class Span { class = typename std::enable_if< detail::is_allowed_element_type_conversion_t::value && detail::is_allowed_extent_conversion_t::value>> - constexpr Span(const Span& _other) noexcept + constexpr span_t(const span_t& _other) noexcept : size_(_other.size()), data_(_other.data()) { } - constexpr Span(const Span& _other) noexcept : size_(_other.size()), data_(_other.data()) {} + constexpr span_t(const span_t& _other) noexcept : size_(_other.size()), data_(_other.data()) {} - constexpr auto operator=(const Span& _other) noexcept -> Span& + constexpr auto operator=(const span_t& _other) noexcept -> span_t& { size_ = _other.size(); data_ = _other.data(); @@ -205,26 +205,26 @@ class Span { // Subviews template - constexpr auto first() const -> Span + constexpr auto first() const -> span_t { assert(Count <= size()); return {data(), Count}; } - constexpr auto first(std::size_t _count) const -> Span + constexpr auto first(std::size_t _count) const -> span_t { assert(_count <= size()); return {data(), _count}; } template - constexpr auto last() const -> Span + constexpr auto last() const -> span_t { assert(Count <= size()); return {data() + size() - Count, Count}; } - constexpr auto last(std::size_t _count) const -> Span + constexpr auto last(std::size_t _count) const -> span_t { assert(_count <= size()); return subspan(size() - _count, _count); @@ -236,14 +236,14 @@ class Span { */ template constexpr auto subspan() const - -> Span::value> + -> span_t::value> { assert((Count == dynamic_extent) ? (Offset <= size()) : (Offset + Count <= size())); return {data() + Offset, Count == dynamic_extent ? size() - Offset : Count}; } constexpr auto subspan(size_type _offset, size_type _count = dynamic_extent) const - -> Span + -> span_t { assert((_count == dynamic_extent) ? (_offset <= size()) : (_offset + _count <= size())); return {data() + _offset, _count == dynamic_extent ? size() - _offset : _count}; @@ -255,13 +255,13 @@ class Span { }; template -using host_span_t = Span; +using host_span_t = span_t; template -using device_span_t = Span; +using device_span_t = span_t; template -constexpr auto operator==(Span l, Span r) -> bool +constexpr auto operator==(span_t l, span_t r) -> bool { if (l.size() != r.size()) { return false; } for (auto l_beg = l.cbegin(), r_beg = r.cbegin(); l_beg != l.cend(); ++l_beg, ++r_beg) { @@ -271,53 +271,53 @@ constexpr auto operator==(Span l, Span r) -> b } template -constexpr auto operator!=(Span l, Span r) +constexpr auto operator!=(span_t l, span_t r) { return !(l == r); } template -constexpr auto operator<(Span l, Span r) +constexpr auto operator<(span_t l, span_t r) { return detail::lexicographical_compare< - typename Span::iterator, - typename Span::iterator, - thrust::less::element_type>>( + typename span_t::iterator, + typename span_t::iterator, + thrust::less::element_type>>( l.begin(), l.end(), r.begin(), r.end()); } template -constexpr auto operator<=(Span l, Span r) +constexpr auto operator<=(span_t l, span_t r) { return !(l > r); } template -constexpr auto operator>(Span l, Span r) +constexpr auto operator>(span_t l, span_t r) { return detail::lexicographical_compare< - typename Span::iterator, - typename Span::iterator, - thrust::greater::element_type>>( + typename span_t::iterator, + typename span_t::iterator, + thrust::greater::element_type>>( l.begin(), l.end(), r.begin(), r.end()); } template -constexpr auto operator>=(Span l, Span r) +constexpr auto operator>=(span_t l, span_t r) { return !(l < r); } template -auto as_bytes(Span s) noexcept - -> Span::value> +auto as_bytes(span_t s) noexcept + -> span_t::value> { return {reinterpret_cast(s.data()), s.size_bytes()}; } template -auto as_writable_bytes(Span s) noexcept - -> Span::value> +auto as_writable_bytes(span_t s) noexcept + -> span_t::value> { return {reinterpret_cast(s.data()), s.size_bytes()}; } diff --git a/cpp/test/common/test_span.hpp b/cpp/test/common/test_span.hpp index 464fc3ec3d..3eb2ca74ad 100644 --- a/cpp/test/common/test_span.hpp +++ b/cpp/test/common/test_span.hpp @@ -50,11 +50,11 @@ struct test_assignment_t { __host__ __device__ void operator()() { this->operator()(0); } __host__ __device__ void operator()(int _idx) { - Span s1; + span_t s1; float arr[] = {3, 4, 5}; - Span s2 = arr; + span_t s2 = arr; SPAN_ASSERT_TRUE(s2.size() == 3, status); SPAN_ASSERT_TRUE(s2.data() == &arr[0], status); @@ -75,9 +75,9 @@ struct test_beginend_t { float arr[16]; initialize_range(arr, arr + 16); - Span s(arr); - typename Span::iterator beg{s.begin()}; - typename Span::iterator end{s.end()}; + span_t s(arr); + typename span_t::iterator beg{s.begin()}; + typename span_t::iterator end{s.end()}; SPAN_ASSERT_TRUE(end == beg + 16, status); SPAN_ASSERT_TRUE(*beg == arr[0], status); @@ -97,17 +97,17 @@ struct test_rbeginrend_t { float arr[16]; initialize_range(arr, arr + 16); - Span s(arr); + span_t s(arr); s.rbegin(); - typename Span::reverse_iterator rbeg{s.rbegin()}; - typename Span::reverse_iterator rend{s.rend()}; + typename span_t::reverse_iterator rbeg{s.rbegin()}; + typename span_t::reverse_iterator rend{s.rend()}; SPAN_ASSERT_TRUE(rbeg + 16 == rend, status); SPAN_ASSERT_TRUE(*(rbeg) == arr[15], status); SPAN_ASSERT_TRUE(*(rend - 1) == arr[0], status); - typename Span::const_reverse_iterator crbeg{s.crbegin()}; - typename Span::const_reverse_iterator crend{s.crend()}; + typename span_t::const_reverse_iterator crbeg{s.crbegin()}; + typename span_t::const_reverse_iterator crend{s.crend()}; SPAN_ASSERT_TRUE(crbeg + 16 == crend, status); SPAN_ASSERT_TRUE(*(crbeg) == arr[15], status); @@ -127,14 +127,14 @@ struct test_observers_t { // empty { float* arr = nullptr; - Span s(arr, static_cast::size_type>(0)); + span_t s(arr, static_cast::size_type>(0)); SPAN_ASSERT_TRUE(s.empty(), status); } // size, size_types { float* arr = new float[16]; - Span s(arr, 16); + span_t s(arr, 16); SPAN_ASSERT_TRUE(s.size() == 16, status); SPAN_ASSERT_TRUE(s.size_bytes() == 16 * sizeof(float), status); delete[] arr; @@ -155,8 +155,8 @@ struct test_compare_t { initialize_range(lhs_arr, lhs_arr + 16); initialize_range(rhs_arr, rhs_arr + 16); - Span lhs(lhs_arr); - Span rhs(rhs_arr); + span_t lhs(lhs_arr); + span_t rhs(rhs_arr); SPAN_ASSERT_TRUE(lhs == rhs, status); SPAN_ASSERT_FALSE(lhs != rhs, status); @@ -185,16 +185,16 @@ struct test_as_bytes_t { initialize_range(arr, arr + 16); { - const Span s{arr}; - const Span bs = as_bytes(s); + const span_t s{arr}; + const span_t bs = as_bytes(s); SPAN_ASSERT_TRUE(bs.size() == s.size_bytes(), status); SPAN_ASSERT_TRUE(static_cast(bs.data()) == static_cast(s.data()), status); } { - Span s; - const Span bs = as_bytes(s); + span_t s; + const span_t bs = as_bytes(s); SPAN_ASSERT_TRUE(bs.size() == s.size(), status); SPAN_ASSERT_TRUE(bs.size() == 0, status); SPAN_ASSERT_TRUE(bs.size_bytes() == 0, status); @@ -218,8 +218,8 @@ struct test_as_writable_bytes_t { initialize_range(arr, arr + 16); { - Span s; - Span byte_s = as_writable_bytes(s); + span_t s; + span_t byte_s = as_writable_bytes(s); SPAN_ASSERT_TRUE(byte_s.size() == s.size(), status); SPAN_ASSERT_TRUE(byte_s.size_bytes() == s.size_bytes(), status); SPAN_ASSERT_TRUE(byte_s.size() == 0, status); @@ -229,8 +229,8 @@ struct test_as_writable_bytes_t { } { - Span s{arr}; - Span bs{as_writable_bytes(s)}; + span_t s{arr}; + span_t bs{as_writable_bytes(s)}; SPAN_ASSERT_TRUE(s.size_bytes() == bs.size_bytes(), status); SPAN_ASSERT_TRUE(static_cast(bs.data()) == static_cast(s.data()), status); }