LCOV - code coverage report
Current view: top level - legacy/ascend950/common - iterator_unconst.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 14 14
Test Date: 2026-07-28 12:11:00 Functions: 75.0 % 16 12

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #ifndef HCCLV2_ITERATOR_UNCONST_H
      12              : #define HCCLV2_ITERATOR_UNCONST_H
      13              : 
      14              : 
      15              : namespace Hccl {
      16              : using namespace std;
      17              : 
      18              : template <template <class U, typename _Alloc = std::allocator<U>> class Sequence, typename T, typename Enable = void>
      19              : class BaseIterator {};
      20              :  
      21              : template <template <class U, typename _Alloc = std::allocator<U>> class Sequence, typename T>
      22              : class BaseIterator<Sequence, T, typename enable_if<IsSharedPtr<T>::value || IsUniquePtr<T>::value>::type> {
      23              : public:
      24              :     using V = typename T::element_type;
      25              :  
      26              :     BaseIterator(): iter(nullptr), end(nullptr) {};
      27              :  
      28           23 :     explicit BaseIterator(Sequence<T> &seq) : iter(seq.begin()), end(seq.end()){};
      29           29 :     virtual ~BaseIterator() {};
      30              :  
      31            6 :     virtual V &operator*()
      32              :     {
      33            6 :         return *(*iter);
      34              :     };
      35              :  
      36           19 :     virtual V *operator->()
      37              :     {
      38           19 :         return (*iter).get();
      39              :     };
      40              :  
      41            1 :     virtual BaseIterator &Next()
      42              :     {
      43            1 :         iter++;
      44            1 :         return *this;
      45              :     };
      46              :  
      47           15 :     virtual BaseIterator &operator++()
      48              :     {
      49           15 :         iter++;
      50           15 :         return *this;
      51              :     }
      52              :  
      53           32 :     virtual bool HasNext()
      54              :     {
      55           32 :         return iter != end;
      56              :     };
      57              :  
      58              : protected:
      59              :     typename Sequence<T>::iterator iter;
      60              :     typename Sequence<T>::iterator end;
      61              : };
      62              : 
      63              : 
      64              : } // namespace Hccl
      65              : 
      66              : #endif // HCCLV2_ITERATOR_H
        

Generated by: LCOV version 2.0-1