LCOV - code coverage report
Current view: top level - runtime_compact/c_base/inc - sort_vector.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 5 0
Test Date: 2026-08-06 15:29:52 Functions: 0.0 % 2 0

            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              : #ifndef C_BASE_SORT_VECTOR_H
      11              : #define C_BASE_SORT_VECTOR_H
      12              : #include "c_base.h"
      13              : #include "binary_search.h"
      14              : #include "vector.h"
      15              : #ifdef __cplusplus
      16              : extern "C" {
      17              : #endif
      18              : 
      19              : typedef struct {
      20              :     void *appInfo;
      21              :     FnBinaryCompare fnCmp;
      22              :     Vector vector;
      23              : } SortVector;
      24              : 
      25              : #define NewSortVector(objType, pfnCmp, appInfo) CreateSortVector(sizeof(objType), pfnCmp, appInfo)
      26              : 
      27              : // itemSize 不能为0,请调用者保证
      28              : // appInfo 该参数只会透传给pfnCmp使用,为空是否合法由调用者自己判断
      29              : void InitSortVector(SortVector *sortVector, size_t itemSize, FnBinaryCompare pfnCmp, void *appInfo);
      30            0 : static inline void SetSortVectorDestroyItem(SortVector *sortVector, FnDestroy pfnDestroyItem)
      31              : {
      32            0 :     SetVectorDestroyItem(&sortVector->vector, pfnDestroyItem);
      33            0 : }
      34              : void DeInitSortVector(SortVector *vector);
      35              : 
      36              : // itemSize 不能为0,请调用者保证
      37              : SortVector *CreateSortVector(size_t itemSize, FnBinaryCompare pfnCmp, void *appInfo);
      38              : void DestroySortVector(SortVector *sortVector);
      39              : size_t CapacitySortVector(SortVector *sortVector, size_t capacity);
      40            0 : static inline size_t SortVectorSize(SortVector *sortVector)
      41              : {
      42            0 :     return VectorSize(&sortVector->vector);
      43              : };
      44              : void *SortVectorAt(SortVector *sortVector, size_t index);
      45              : size_t FindSortVector(SortVector *sortVector, void *key);
      46              : void *SortVectorAtKey(SortVector *sortVector, void *key);
      47              : void *EmplaceSortVector(SortVector *sortVector, void *data);
      48              : void RemoveSortVector(SortVector *sortVector, size_t index);
      49              : #ifdef __cplusplus
      50              : }
      51              : #endif
      52              : #endif // C_BASE_SORT_VECTOR_H
        

Generated by: LCOV version 2.0-1