ObjFW
OFMutableDictionary.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFDictionary.h"
18 
19 OF_ASSUME_NONNULL_BEGIN
20 
23 #ifdef OF_HAVE_BLOCKS
24 
31 typedef id OF_NONNULL (^of_dictionary_replace_block_t)(id key, id object);
32 #endif
33 
39 #ifdef OF_HAVE_GENERICS
40 @interface OFMutableDictionary <KeyType, ObjectType>:
41  OFDictionary <KeyType, ObjectType>
42 #else
43 # ifndef DOXYGEN
44 # define KeyType id
45 # define ObjectType id
46 # endif
48 #endif
49 
56 + (instancetype)dictionaryWithCapacity: (size_t)capacity;
57 
65 - initWithCapacity: (size_t)capacity;
66 
75 - (void)setObject: (ObjectType)object
76  forKey: (KeyType)key;
77 - (void)setObject: (ObjectType)object
78  forKeyedSubscript: (KeyType)key;
79 
85 - (void)removeObjectForKey: (KeyType)key;
86 
90 - (void)removeAllObjects;
91 
92 #ifdef OF_HAVE_BLOCKS
93 
98 - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block;
99 #endif
100 
104 - (void)makeImmutable;
105 @end
106 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
107 # undef KeyType
108 # undef ObjectType
109 #endif
110 
111 OF_ASSUME_NONNULL_END
An abstract class for storing and changing objects in a dictionary.
Definition: OFMutableDictionary.h:47
void removeAllObjects()
Removes all objects.
Definition: OFMutableDictionary.m:184
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:61
id OF_NONNULL(^ of_dictionary_replace_block_t)(id key, id object)
A block for replacing objects in an OFMutableDictionary.
Definition: OFMutableDictionary.h:31
void makeImmutable()
Converts the mutable dictionary to an immutable dictionary.
Definition: OFMutableDictionary.m:217