ObjFW
OFMutableDictionary.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
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 _Nonnull (^of_dictionary_replace_block_t)(id key, id object);
32 #endif
33 
39 @interface OFMutableDictionary OF_GENERIC(KeyType, ObjectType):
40  OFDictionary OF_GENERIC(KeyType, ObjectType)
41 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
42 # define KeyType id
43 # define ObjectType id
44 #endif
45 
52 + (instancetype)dictionaryWithCapacity: (size_t)capacity;
53 
61 - initWithCapacity: (size_t)capacity;
62 
71 - (void)setObject: (ObjectType)object
72  forKey: (KeyType)key;
73 - (void)setObject: (ObjectType)object
74  forKeyedSubscript: (KeyType)key;
75 
81 - (void)removeObjectForKey: (KeyType)key;
82 
86 - (void)removeAllObjects;
87 
93 - (void)addEntriesFromDictionary:
94  (OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
95 
96 #ifdef OF_HAVE_BLOCKS
97 
102 - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block;
103 #endif
104 
108 - (void)makeImmutable;
109 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
110 # undef KeyType
111 # undef ObjectType
112 #endif
113 @end
114 
115 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:31
An abstract class for storing and changing objects in a dictionary.
Definition: OFMutableDictionary.h:39
void removeAllObjects()
Removes all objects.
Definition: OFMutableDictionary.m:182
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:54
void makeImmutable()
Converts the mutable dictionary to an immutable dictionary.
Definition: OFMutableDictionary.m:227