• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LNN_MAP_H
17 #define LNN_MAP_H
18 
19 #include <stdint.h>
20 #include <stdbool.h>
21 #include "lnn_map_struct.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 MapIterator *LnnMapInitIterator(Map *map);
28 bool LnnMapHasNext(MapIterator *it);
29 MapIterator *LnnMapNext(MapIterator *it);
30 void LnnMapDeinitIterator(MapIterator *it);
31 
32 /**
33  * Initialize map
34  *
35  * @param : map Map see details in type Map
36  */
37 void LnnMapInit(Map *map);
38 
39 /**
40  * Delete map, free the map memory
41  *
42  * @param : map Map see details in type Map
43  */
44 void LnnMapDelete(Map *map);
45 
46 /**
47  * Add map element
48  *
49  * @param : map Map see details in type Map
50  *          key Map key
51  *          value Map value
52  *          valueSize Map value size
53  * @return : SOFTBUS_OK or other error
54  */
55 int32_t LnnMapSet(Map *map, const char *key, const void *value, uint32_t valueSize);
56 
57 /**
58  * Get map value
59  *
60  * @param : map Map see details in type Map
61  *          key Map key
62  * @return : Value of key or NULL
63  */
64 void *LnnMapGet(const Map *map, const char *key);
65 
66 /**
67  * Erase map element
68  * Erase cannot be used on the iterator
69  *
70  * @param : map Map see details in type Map
71  *          key Map key
72  */
73 int32_t LnnMapErase(Map *map, const char *key);
74 
75 /**
76  * get map size
77  *
78  * @param : map Map see details in type Map
79  */
80 uint32_t MapGetSize(Map *map);
81 
82 #ifdef __cplusplus
83 }
84 #endif /* __cplusplus */
85 
86 #endif /* LNN_MAP_H */
87