Samond Classes Library 1.2.6-STABLE build 219
SCOrderedSet.h
Go to the documentation of this file.
1 //
2 // SCOrderedSet.h
3 // scl
4 //
5 // Created by Viacheslav Smolensky on 04.02.16.
6 // Copyright (c) 2007 - 2018 by Samond Development Corporation. All rights reserved.
7 //
8 
22 #import <Foundation/Foundation.h>
23 #if defined(GNUSTEP) && !defined(NS_ORDERED_SER_CLASS)
24 #import <scl/NSMutableOrderedSet.h>
25 #endif
26 #import <scl/NSArray+SCArray.h>
28 #import <scl/SCCollection.h>
29 #import <scl/SCSorter.h>
30 
31 #pragma mark -
32 #pragma mark Class Constants
33 
42 #define SCOrderedSetClass @"SCOrderedSet"
43 
84  NSMutableOrderedSet *_orderedSet; // Internal data storage
85 }
86 
112 @property (nonatomic, readonly, assign) SCOrderedSet *ascendingSortedOrderedSet;
113 
118 @property (nonatomic, readonly, assign) SCOrderedSet *descendingSortedOrderedSet;
119 
127 @property (nonatomic, readonly, assign) SCOrderedSet *sortedOrderedSet;
128 
148 @property (nonatomic, readonly, assign) SCArray *allObjects;
149 
154 @property (nonatomic, readonly, assign) id firstObject;
155 
160 @property (nonatomic, readonly, assign) id lastObject;
161 
166 @property (nonatomic, readonly, assign) SCOrderedSet *reversedOrderedSet;
167 
179 @property (nonatomic, readonly, assign) SCIndex indexOfLastObject;
180 
183 #pragma mark -
184 #pragma mark Creating Ordered Sets
185 + (instancetype)orderedSetWithCoder:(NSCoder *)coder;
186 + (instancetype)orderedSetWithContentsOfSerializedFile:(NSString *)path;
187 + (instancetype)orderedSetWithDataDictionary:(NSDictionary *)dictionary;
188 + (instancetype)orderedSetWithDataDictionaryFromFile:(NSString *)path;
189 + (instancetype)orderedSetWithStream:(SCStream *)stream;
190 + (instancetype)orderedSetWithFileStream:(NSString *)path;
191 + (instancetype)orderedSetWithData:(NSData *)data;
192 + (instancetype)orderedSetWithContentsOfFile:(NSString *)path;
193 + (instancetype)orderedSetWithContentsOfURL:(NSURL *)url;
194 + (instancetype)orderedSetWithContentsOfURLString:(NSString *)urlString;
195 
196 + (instancetype)orderedSetWithName:(NSString *)name;
197 + (instancetype)orderedSetWithObject:(id<SCCollectioning>)object;
198 + (instancetype)orderedSetWithObjects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
199 + (instancetype)orderedSetWithCollection:(id<SCCollection>)collection;
200 + (instancetype)orderedSetWithArray:(SCArray *)array;
201 + (instancetype)orderedSetWithSet:(SCSet *)set;
202 + (instancetype)orderedSetWithOrderedSet:(SCOrderedSet *)orderedSet;
203 + (instancetype)orderedSet;
204 
205 + (instancetype)orderedSetWithAscendingSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
206 + (instancetype)orderedSetWithDescendingSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
207 + (instancetype)orderedSetWithSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
208 + (instancetype)orderedSetWithAscendingSortedCollection:(id<SCCollection>)collection;
209 + (instancetype)orderedSetWithDescendingSortedCollection:(id<SCCollection>)collection;
210 + (instancetype)orderedSetWithSortedCollection:(id<SCCollection>)collection;
211 
212 #pragma mark -
213 #pragma mark Initializing Ordered Sets
214 - (instancetype)initWithName:(NSString *)name;
215 - (instancetype)initWithObject:(id<SCCollectioning>)object;
216 - (instancetype)initWithObjects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
217 - (instancetype)initWithCollection:(id<SCCollection>)collection;
218 - (instancetype)initWithArray:(SCArray *)array;
219 - (instancetype)initWithSet:(SCSet *)set;
220 - (instancetype)initWithOrderedSet:(SCOrderedSet *)orderedSet;
221 - (instancetype)init;
222 
223 - (instancetype)initWithAscendingSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
224 - (instancetype)initWithDescendingSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
225 - (instancetype)initWithSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
226 - (instancetype)initWithAscendingSortedCollection:(id<SCCollection>)collection;
227 - (instancetype)initWithDescendingSortedCollection:(id<SCCollection>)collection;
228 - (instancetype)initWithSortedCollection:(id<SCCollection>)collection;
229 
230 #pragma mark -
231 #pragma mark Copying Ordered Sets
232 - (void)setSet:(SCSet *)set;
233 - (void)setOrderedSet:(SCOrderedSet *)orderedSet;
234 - (void)setArray:(SCArray *)array;
235 - (void)setAscendingSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
236 - (void)setDescendingSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
237 - (void)setSortedCollection:(id<SCCollection>)collection sorter:(id<SCSorter>)sorter;
238 - (void)setAscendingSortedCollection:(id<SCCollection>)collection;
239 - (void)setDescendingSortedCollection:(id<SCCollection>)collection;
240 - (void)setSortedCollection:(id<SCCollection>)collection;
241 
242 #pragma mark -
243 #pragma mark Comparing Ordered Sets
244 - (BOOL)isSubsetOfOrderedSet:(id<SCCollection>)orderedSet;
245 - (BOOL)isSubsetOfSet:(id<SCCollection>)set;
246 - (BOOL)intersectsOrderedSet:(id<SCCollection>)orderedSet;
247 - (BOOL)intersectsSet:(id<SCCollection>)set;
248 - (BOOL)isEqualToOrderedSet:(SCOrderedSet *)orderedSet;
249 - (BOOL)isEqualToSet:(SCSet *)set;
250 - (BOOL)isEqualToArray:(SCArray *)array;
251 
252 #pragma mark -
253 #pragma mark Deriving New Ordered Sets
254 - (SCOrderedSet *)orderedSetByAddingObject:(id<SCCollectioning>)object;
255 - (SCOrderedSet *)orderedSetByAddingObjects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
256 - (SCOrderedSet *)orderedSetByAddingCollection:(id<SCCollection>)collection;
257 - (SCOrderedSet *)orderedSetByAddingObjectsFromArray:(SCArray *)array;
258 - (SCOrderedSet *)orderedSetByAddingArray:(SCArray *)array;
259 - (SCOrderedSet *)orderedSetByAddingObjectsFromSet:(SCSet *)set;
260 - (SCOrderedSet *)orderedSetByAddingSet:(SCSet *)set;
261 - (SCOrderedSet *)orderedSetByAddingObjectsFromOrderedSet:(SCOrderedSet *)orderedSet;
262 - (SCOrderedSet *)orderedSetByAddingOrderedSet:(SCOrderedSet *)orderedSet;
263 
264 #pragma mark -
265 #pragma mark Sorting Ordered Sets
266 - (void)sortAscendingWithSorter:(id<SCSorter>)sorter;
267 - (void)sortDescendingWithSorter:(id<SCSorter>)sorter;
268 - (void)sortWithSorter:(id<SCSorter>)sorter;
269 - (void)sortAscending;
270 - (void)sortDescending;
271 - (void)sort;
272 - (SCOrderedSet *)ascendingSortedOrderedSetWithSorter:(id<SCSorter>)sorter;
273 - (SCOrderedSet *)descendingSortedOrderedSetWithSorter:(id<SCSorter>)sorter;
274 - (SCOrderedSet *)sortedOrderedSetWithSorter:(id<SCSorter>)sorter;
275 
276 #pragma mark -
277 #pragma mark Adding Objects
278 - (void)insertObject:(id<SCCollectioning>)object atIndex:(SCIndex)index;
279 - (void)insertAtIndex:(SCIndex)index objects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
280 - (void)insertCollection:(id<SCCollection>)collection atIndex:(SCIndex)index;
281 - (void)insertAtIndexes:(NSIndexSet *)indexes objects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
282 - (void)insertCollection:(id<SCCollection>)collection atIndexes:(NSIndexSet *)indexes;
283 - (void)setObject:(id<SCCollectioning>)object atIndex:(SCIndex)index;
284 - (void)addObjectsFromArray:(SCArray *)array;
285 - (void)addArray:(SCArray *)array;
286 - (void)addObjectsFromSet:(SCSet *)set;
287 - (void)addSet:(SCSet *)set;
288 - (void)addObjectsFromOrderedSet:(SCOrderedSet *)orderedSet;
289 - (void)addOrderedSet:(SCOrderedSet *)orderedSet;
290 
291 #pragma mark -
292 #pragma mark Removing Objects
293 - (void)removeFirstObject;
294 - (void)removeLastObject;
295 - (void)removeObjectAtIndex:(SCIndex)index;
296 - (void)removeObjectsAtIndexes:(NSIndexSet *)indexes;
297 - (void)removeObjectsInRange:(NSRange)range;
298 
299 #pragma mark -
300 #pragma mark Replacing Objects
301 - (void)replaceObjectAtIndex:(SCIndex)index withObject:(id<SCCollectioning>)object;
302 - (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes
303  withObjects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
304 - (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withCollection:(id<SCCollection>)collection;
305 - (void)replaceObjectsInRange:(NSRange)range withObjects:(id<SCCollectioning>)object, ... NS_REQUIRES_NIL_TERMINATION;
306 - (void)replaceObjectsInRange:(NSRange)range withCollection:(id<SCCollection>)collection;
307 - (void)setObject:(id<SCCollectioning>)object atIndexedSubscript:(SCIndex)index;
308 
309 #pragma mark -
310 #pragma mark Moving Objects
311 - (void)exchangeObjectAtIndex:(SCIndex)index withObjectAtIndex:(SCIndex)destination;
312 - (void)moveObjectAtIndex:(SCIndex)index toIndex:(SCIndex)destination;
313 - (void)reverse;
314 
315 #pragma mark -
316 #pragma mark Querying an Ordered Set
317 - (id)objectAtIndex:(SCIndex)index;
318 - (SCArray *)objectsAtIndexes:(NSIndexSet *)indexes;
319 - (id)objectAtIndexedSubscript:(SCIndex)index;
320 
321 #pragma mark -
322 #pragma mark Finding Objects in an Ordered Set
323 - (SCIndex)indexOfObject:(id<SCCollectioning>)object;
324 
325 #pragma mark -
326 #pragma mark Combining and Recombining Ordered Sets
327 - (void)unionOrderedSet:(id<SCCollection>)orderedSet;
328 - (void)unionSet:(id<SCCollection>)set;
329 - (void)minusOrderedSet:(id<SCCollection>)set;
330 - (void)minusSet:(id<SCCollection>)set;
331 - (void)intersectOrderedSet:(id<SCCollection>)orderedSet;
332 - (void)intersectSet:(id<SCCollection>)set;
333 
334 @end
Unordered set class.
Definition: SCSet.h:72
Mutable indexed collection protocol.
Definition: SCCollectionProtocols.h:887
Caregory NSArray(SCArray) header file.
Ordered set class.
Definition: SCOrderedSet.h:83
Abstract implementation of the protocol SCSorter.
Definition: SCSorter.h:138
Indexed collections protocol.
Definition: SCCollectionProtocols.h:793
Protocol and class SCSorter header file.
Collections communications protocol.
Definition: SCCollectioning.h:79
Category NSDictionary(SCDictionary) header file.
Abstract collections class.
Definition: SCCollection.h:98
Class SCCollection header file.
Array class.
Definition: SCArray.h:84
NSUInteger SCIndex
Definition: SCCollectionProtocols.h:53
Abstract parent class of the stream classes hierarchy.
Definition: SCStream.h:224