2 * Copyright (c) 2019 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (mhe 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 OS_ASSUME_NONNULL_BEGIN
27 #define os_map_t IN_MAP(,_t)
31 IN_MAP(,_init
)(os_map_t
*m
, os_map_config_t
* _Nullable config
,
34 OS_OVERLOADABLE OS_ALWAYS_INLINE
36 os_map_init(os_map_t
*m
, os_map_config_t
* _Nullable config
) {
37 IN_MAP(,_init
)(m
, config
, OS_MAP_CONFIG_S_VERSION
);
42 IN_MAP(,_destroy
)(os_map_t
*m
);
44 OS_OVERLOADABLE OS_ALWAYS_INLINE
46 os_map_destroy(os_map_t
*m
) {
52 IN_MAP(,_insert
)(os_map_t
*m
, os_map_key_t key
, void *val
);
54 OS_OVERLOADABLE OS_ALWAYS_INLINE
56 os_map_insert(os_map_t
*m
, os_map_key_t key
, void *val
) {
57 IN_MAP(,_insert
)(m
, key
, val
);
62 IN_MAP(,_find
)(os_map_t
*m
, os_map_key_t key
);
64 OS_OVERLOADABLE OS_ALWAYS_INLINE
65 static inline void * _Nullable
66 os_map_find(os_map_t
*m
, os_map_key_t key
) {
67 return IN_MAP(,_find
)(m
, key
);
72 IN_MAP(,_delete
)(os_map_t
*m
, os_map_key_t key
);
74 OS_OVERLOADABLE OS_ALWAYS_INLINE
75 static inline void * _Nullable
76 os_map_delete(os_map_t
*m
, os_map_key_t key
) {
77 return IN_MAP(,_delete
)(m
, key
);
82 IN_MAP(,_clear
)(os_map_t
*m
,
83 OS_NOESCAPE
IN_MAP(,_payload_handler_t
) handler
);
85 OS_OVERLOADABLE OS_ALWAYS_INLINE
87 os_map_clear(os_map_t
*m
,
88 OS_NOESCAPE
IN_MAP(,_payload_handler_t
) handler
) {
89 IN_MAP(,_clear
)(m
, handler
);
94 IN_MAP(,_count
)(os_map_t
*m
);
96 OS_OVERLOADABLE OS_ALWAYS_INLINE
98 os_map_count(os_map_t
*m
) {
99 return IN_MAP(,_count
)(m
);
104 IN_MAP(,_foreach
)(os_map_t
*m
,
105 OS_NOESCAPE
IN_MAP(,_payload_handler_t
) handler
);
107 OS_OVERLOADABLE OS_ALWAYS_INLINE
109 os_map_foreach(os_map_t
*m
,
110 OS_NOESCAPE
IN_MAP(,_payload_handler_t
) handler
) {
111 IN_MAP(,_foreach
)(m
, handler
);
115 OS_ASSUME_NONNULL_END