ObjFW
Loading...
Searching...
No Matches
OFMutableDictionary.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2024 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
18OF_ASSUME_NONNULL_BEGIN
19
22#ifdef OF_HAVE_BLOCKS
30typedef id _Nonnull (^OFDictionaryReplaceBlock)(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
62- (instancetype)init OF_DESIGNATED_INITIALIZER;
63
71- (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER;
72
81- (void)setObject: (ObjectType)object forKey: (KeyType)key;
82
94- (void)setObject: (nullable ObjectType)object forKeyedSubscript: (KeyType)key;
95
101- (void)removeObjectForKey: (KeyType)key;
102
106- (void)removeAllObjects;
107
113- (void)addEntriesFromDictionary:
114 (OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
115
116#ifdef OF_HAVE_BLOCKS
122- (void)replaceObjectsUsingBlock: (OFDictionaryReplaceBlock)block;
123#endif
124
128- (void)makeImmutable;
129#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
130# undef KeyType
131# undef ObjectType
132#endif
133@end
134
135OF_ASSUME_NONNULL_END
id(^ OFDictionaryReplaceBlock)(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:80
An abstract class for storing and changing objects in a dictionary.
Definition OFMutableDictionary.h:44
void removeAllObjects()
Removes all objects.
Definition OFMutableDictionary.m:157
void makeImmutable()
Converts the mutable dictionary to an immutable dictionary.
Definition OFMutableDictionary.m:200
instancetype init()
Initializes an already allocated OFMutableDictionary to be empty.
Definition OFMutableDictionary.m:113