ObjFW
OFMutableDictionary.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFDictionary.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
22 #ifdef OF_HAVE_BLOCKS
30 typedef id _Nonnull (^of_dictionary_replace_block_t)(id key, id object);
31 #endif
32 
42 @interface OFMutableDictionary OF_GENERIC(KeyType, ObjectType):
43  OFDictionary OF_GENERIC(KeyType, ObjectType)
44 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
45 # define KeyType id
46 # define ObjectType id
47 #endif
55 + (instancetype)dictionaryWithCapacity: (size_t)capacity;
56 
64 - (instancetype)initWithCapacity: (size_t)capacity;
65 
74 - (void)setObject: (ObjectType)object forKey: (KeyType)key;
75 
87 - (void)setObject: (nullable ObjectType)object forKeyedSubscript: (KeyType)key;
88 
94 - (void)removeObjectForKey: (KeyType)key;
95 
99 - (void)removeAllObjects;
100 
106 - (void)addEntriesFromDictionary:
107  (OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
108 
109 #ifdef OF_HAVE_BLOCKS
115 - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block;
116 #endif
117 
121 - (void)makeImmutable;
122 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
123 # undef KeyType
124 # undef ObjectType
125 #endif
126 @end
127 
128 OF_ASSUME_NONNULL_END
id _Nonnull(^ of_dictionary_replace_block_t)(id key, id object)
A block for replacing objects in an OFMutableDictionary.
Definition: OFMutableDictionary.h:30
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:58
An abstract class for storing and changing objects in a dictionary.
Definition: OFMutableDictionary.h:44
void removeAllObjects()
Removes all objects.
Definition: OFMutableDictionary.m:174
void makeImmutable()
Converts the mutable dictionary to an immutable dictionary.
Definition: OFMutableDictionary.m:217