Samond Classes Library 1.2.0-RELEASE build 166
SCArray.h
Go to the documentation of this file.
1 //
2 // SCArray.h
3 // scl
4 //
5 // Created by Viacheslav Smolensky on 13.04.12.
6 // Copyright (c) 2007 - 2017 by Samond Development Corporation. All rights reserved.
7 //
8 
22 #import <scl/SCCollection.h>
23 #import <scl/SCSorter.h>
24 #import <scl/SCIndexedCollection.h>
25 #import <scl/SCMutableIndexedCollection.h>
26 
27 #pragma mark -
28 #pragma mark Константы класса
29 
33 #define SCArrayClass @"SCArray"
34 
35 
78  NSMutableArray *fArray; // Внутреннее представление данных
79 }
80 
100 @property (nonatomic, retain, readonly, getter=sortedArray) SCArray *sortedArray;
101 // Отсортированный по возрастанию массив (<i><b>только для чтения</b></i>)
102 
120 @property (nonatomic, retain, readonly, getter=reversedArray) SCArray *reversedArray;
121 
133 @property (nonatomic, retain, readonly, getter=firstObject) id firstObject;
134 
139 @property (nonatomic, retain, readonly, getter=firstString) NSString *firstString;
140 
145 @property (nonatomic, retain, readonly, getter=firstNumber) NSNumber *firstNumber;
146 
151 @property (nonatomic, retain, readonly, getter=lastObject) id lastObject;
152 
157 @property (nonatomic, retain, readonly, getter=lastString) NSString *lastString;
158 
163 @property (nonatomic, retain, readonly, getter=lastNumber) NSNumber *lastNumber;
164 
176 @property (nonatomic, assign, readonly, getter=indexOfLastObject) SCIndex indexOfLastObject;
177 
180 #pragma mark -
181 #pragma mark Создание массивов
182 + (SCArray *)arrayWithCoder:(NSCoder *)coder;
183 + (SCArray *)arrayWithContentsOfSerializedFile:(NSString *)path;
184 + (SCArray *)arrayWithDataDictionary:(NSDictionary *)dictionary;
185 + (SCArray *)arrayWithDataDictionaryFromFile:(NSString *)path;
186 + (SCArray *)arrayWithStream:(SCStream *)stream;
187 + (SCArray *)arrayWithFileStream:(NSString *)path;
188 
189 + (SCArray *)arrayWithName:(NSString *)name;
190 + (SCArray *)arrayWithObject:(id)object;
191 + (SCArray *)arrayWithObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
192 + (SCArray *)arrayWithCollection:(id)collection;
193 + (SCArray *)arrayWithArray:(SCArray *)array;
194 + (SCArray *)array;
195 
196 + (SCArray *)arrayWithAscendingSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
197 + (SCArray *)arrayWithDescendingSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
198 + (SCArray *)arrayWithSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
199 + (SCArray *)arrayWithAscendingSortedCollection:(id)collection;
200 + (SCArray *)arrayWithDescendingSortedCollection:(id)collection;
201 + (SCArray *)arrayWithSortedCollection:(id)collection;
202 
203 #pragma mark -
204 #pragma mark Инициализация массивов
205 - (id)initWithName:(NSString *)name;
206 - (id)initWithObject:(id)object;
207 - (id)initWithObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
208 - (id)initWithCollection:(id)collection;
209 - (id)initWithArray:(SCArray *)array;
210 - (id)init;
211 
212 - (id)initWithAscendingSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
213 - (id)initWithDescendingSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
214 - (id)initWithSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
215 - (id)initWithAscendingSortedCollection:(id)collection;
216 - (id)initWithDescendingSortedCollection:(id)collection;
217 - (id)initWithSortedCollection:(id)collection;
218 
219 #pragma mark -
220 #pragma mark Копирование массивов
221 - (void)setArray:(SCArray *)array;
222 - (void)setAscendingSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
223 - (void)setDescendingSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
224 - (void)setSortedCollection:(id)collection sorter:(id<SCSorter>)sorter;
225 - (void)setAscendingSortedCollection:(id)collection;
226 - (void)setDescendingSortedCollection:(id)collection;
227 - (void)setSortedCollection:(id)collection;
228 
229 #pragma mark -
230 #pragma mark Сравнение массивов
231 - (BOOL)isEqualToArray:(SCArray *)array;
232 - (BOOL)isEqualToContentsOfArray:(SCArray *)array;
233 
234 #pragma mark -
235 #pragma mark Сортировка массивов
236 - (void)sortAscendingWithSorter:(id<SCSorter>)sorter;
237 - (void)sortDescendingWithSorter:(id<SCSorter>)sorter;
238 - (void)sortWithSorter:(id<SCSorter>)sorter;
239 - (void)sortAscending;
240 - (void)sortDescending;
241 - (void)sort;
242 - (SCArray *)ascendingSortedArrayWithSorter:(id<SCSorter>)sorter;
243 - (SCArray *)descendingSortedArrayWithSorter:(id<SCSorter>)sorter;
244 - (SCArray *)sortedArrayWithSorter:(id<SCSorter>)sorter;
245 - (SCArray *)ascendingSortedArray;
246 - (SCArray *)descendingSortedArray;
247 - (SCArray *)sortedArray;
248 
249 #pragma mark -
250 #pragma mark Добавление объектов
251 - (void)insertObject:(id)object atIndex:(SCIndex)index;
252 - (void)insertByte:(SCByte)value atIndex:(SCIndex)index;
253 - (void)insertUByte:(SCUByte)value atIndex:(SCIndex)index;
254 - (void)insertShort:(SCShort)value atIndex:(SCIndex)index;
255 - (void)insertUShort:(SCUShort)value atIndex:(SCIndex)index;
256 - (void)insertInteger:(SCInteger)value atIndex:(SCIndex)index;
257 - (void)insertUInteger:(SCUInteger)value atIndex:(SCIndex)index;
258 - (void)insertLong:(SCLong)value atIndex:(SCIndex)index;
259 - (void)insertULong:(SCULong)value atIndex:(SCIndex)index;
260 - (void)insertChar:(char)value atIndex:(SCIndex)index;
261 - (void)insertUnichar:(unichar)value atIndex:(SCIndex)index;
262 - (void)insertCharString:(const char *)string atIndex:(SCIndex)index;
263 - (void)insertBool:(BOOL)value atIndex:(SCIndex)index;
264 - (void)insertFloat:(SCFloat)value atIndex:(SCIndex)index;
265 - (void)insertDouble:(SCDouble)value atIndex:(SCIndex)index;
266 
267 - (void)setObject:(id)object atIndex:(SCIndex)index;
268 - (void)setByte:(SCByte)value atIndex:(SCIndex)index;
269 - (void)setUByte:(SCUByte)value atIndex:(SCIndex)index;
270 - (void)setShort:(SCShort)value atIndex:(SCIndex)index;
271 - (void)setUShort:(SCUShort)value atIndex:(SCIndex)index;
272 - (void)setInteger:(SCInteger)value atIndex:(SCIndex)index;
273 - (void)setUInteger:(SCUInteger)value atIndex:(SCIndex)index;
274 - (void)setLong:(SCLong)value atIndex:(SCIndex)index;
275 - (void)setULong:(SCULong)value atIndex:(SCIndex)index;
276 - (void)setChar:(char)value atIndex:(SCIndex)index;
277 - (void)setUnichar:(unichar)value atIndex:(SCIndex)index;
278 - (void)setCharString:(const char *)string atIndex:(SCIndex)index;
279 - (void)setBool:(BOOL)value atIndex:(SCIndex)index;
280 - (void)setFloat:(SCFloat)value atIndex:(SCIndex)index;
281 - (void)setDouble:(SCDouble)value atIndex:(SCIndex)index;
282 
283 - (void)insertAtIndex:(SCIndex)index objects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
284 - (void)insertCollection:(id)collection atIndex:(SCIndex)index;
285 - (void)insertAtIndexes:(NSIndexSet *)indexes objects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
286 - (void)insertCollection:(id)collection atIndexes:(NSIndexSet *)indexes;
287 
288 #pragma mark -
289 #pragma mark Удаление объектов
290 - (void)removeFirstObject;
291 - (void)removeLastObject;
292 - (void)removeObjectAtIndex:(SCIndex)index;
293 - (void)removeObjectsAtIndexes:(NSIndexSet *)indexes;
294 - (void)removeObjectsInRange:(NSRange)range;
295 
296 #pragma mark -
297 #pragma mark Замена объектов
298 - (void)replaceObjectAtIndex:(SCIndex)index withObject:(id)object;
299 - (void)replaceObjectAtIndex:(SCIndex)index withByte:(SCByte)value;
300 - (void)replaceObjectAtIndex:(SCIndex)index withUByte:(SCUByte)value;
301 - (void)replaceObjectAtIndex:(SCIndex)index withShort:(SCShort)value;
302 - (void)replaceObjectAtIndex:(SCIndex)index withUShort:(SCUShort)value;
303 - (void)replaceObjectAtIndex:(SCIndex)index withInteger:(SCInteger)value;
304 - (void)replaceObjectAtIndex:(SCIndex)index withUInteger:(SCUInteger)value;
305 - (void)replaceObjectAtIndex:(SCIndex)index withLong:(SCLong)value;
306 - (void)replaceObjectAtIndex:(SCIndex)index withULong:(SCULong)value;
307 - (void)replaceObjectAtIndex:(SCIndex)index withChar:(char)value;
308 - (void)replaceObjectAtIndex:(SCIndex)index withUnichar:(unichar)value;
309 - (void)replaceObjectAtIndex:(SCIndex)index withCharString:(const char *)string;
310 - (void)replaceObjectAtIndex:(SCIndex)index withBool:(BOOL)value;
311 - (void)replaceObjectAtIndex:(SCIndex)index withFloat:(SCFloat)value;
312 - (void)replaceObjectAtIndex:(SCIndex)index withDouble:(SCDouble)value;
313 
314 - (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
315 - (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withCollection:(id)collection;
316 - (void)replaceObjectsInRange:(NSRange)range withObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;
317 - (void)replaceObjectsInRange:(NSRange)range withCollection:(id)collection;
318 
319 #pragma mark -
320 #pragma mark Копирование и перемещение объектов
321 - (void)exchangeObjectAtIndex:(SCIndex)index withObjectAtIndex:(SCIndex)destination;
322 - (void)duplicateObjectAtIndex:(SCIndex)index;
323 - (void)duplicateObjectsInRange:(NSRange)range;
324 - (void)duplicateAllObjects;
325 - (void)duplicate;
326 
327 - (void)copyObjectAtIndex:(SCIndex)index toIndex:(SCIndex)destination;
328 - (void)copyObjectsInRange:(NSRange)range toIndex:(SCIndex)destination;
329 - (void)moveObjectAtIndex:(SCIndex)index toIndex:(SCIndex)destination;
330 - (void)moveObjectsInRange:(NSRange)range toIndex:(SCIndex)destination;
331 
332 - (void)reverse;
333 - (SCArray *)reversedArray;
334 
335 #pragma mark -
336 #pragma mark Доступ к объектам
337 - (id)firstObject;
338 - (NSString *)firstString;
339 - (NSNumber *)firstNumber;
340 - (id)lastObject;
341 - (NSString *)lastString;
342 - (NSNumber *)lastNumber;
343 - (id)objectAtIndex:(SCIndex)index;
344 - (NSString *)stringAtIndex:(SCIndex)index;
345 - (NSNumber *)numberAtIndex:(SCIndex)index;
346 - (SCArray *)objectsAtIndexes:(NSIndexSet *)indexes;
347 - (SCArray *)objectsInRange:(NSRange)range;
348 
349 #pragma mark -
350 #pragma mark Поиск объектов
351 - (SCIndex)indexOfObject:(id)object;
352 - (SCIndex)indexOfByte:(SCByte)value;
353 - (SCIndex)indexOfUByte:(SCUByte)value;
354 - (SCIndex)indexOfShort:(SCShort)value;
355 - (SCIndex)indexOfUShort:(SCUShort)value;
356 - (SCIndex)indexOfInteger:(SCInteger)value;
357 - (SCIndex)indexOfUInteger:(SCUInteger)value;
358 - (SCIndex)indexOfLong:(SCLong)value;
359 - (SCIndex)indexOfULong:(SCULong)value;
360 - (SCIndex)indexOfChar:(char)value;
361 - (SCIndex)indexOfUnichar:(unichar)value;
362 - (SCIndex)indexOfCharString:(const char *)string;
363 - (SCIndex)indexOfBool:(BOOL)value;
364 - (SCIndex)indexOfFloat:(SCFloat)value;
365 - (SCIndex)indexOfDouble:(SCDouble)value;
366 
367 - (SCIndex)indexOfObject:(id)object inRange:(NSRange)range;
368 - (SCIndex)indexOfByte:(SCByte)value inRange:(NSRange)range;
369 - (SCIndex)indexOfUByte:(SCUByte)value inRange:(NSRange)range;
370 - (SCIndex)indexOfShort:(SCShort)value inRange:(NSRange)range;
371 - (SCIndex)indexOfUShort:(SCUShort)value inRange:(NSRange)range;
372 - (SCIndex)indexOfInteger:(SCInteger)value inRange:(NSRange)range;
373 - (SCIndex)indexOfUInteger:(SCUInteger)value inRange:(NSRange)range;
374 - (SCIndex)indexOfLong:(SCLong)value inRange:(NSRange)range;
375 - (SCIndex)indexOfULong:(SCULong)value inRange:(NSRange)range;
376 - (SCIndex)indexOfChar:(char)value inRange:(NSRange)range;
377 - (SCIndex)indexOfUnichar:(unichar)value inRange:(NSRange)range;
378 - (SCIndex)indexOfCharString:(const char *)string inRange:(NSRange)range;
379 - (SCIndex)indexOfBool:(BOOL)value inRange:(NSRange)range;
380 - (SCIndex)indexOfFloat:(SCFloat)value inRange:(NSRange)range;
381 - (SCIndex)indexOfDouble:(SCDouble)value inRange:(NSRange)range;
382 
383 - (SCIndex)indexOfLastObject;
384 
385 @end
uint64_t SCULong
Definition: SCTypes.h:78
int16_t SCShort
Definition: SCTypes.h:42
SCULong SCIndex
Index data type.
Definition: SCTypes.h:240
int64_t SCLong
Definition: SCTypes.h:54
int32_t SCInteger
Definition: SCTypes.h:48
NSNumber * firstNumber
Definition: SCArray.h:145
uint32_t SCUInteger
Definition: SCTypes.h:72
Mutable indexed collection protocol.
Definition: SCMutableIndexedCollection.h:38
int8_t SCByte
Definition: SCTypes.h:36
uint16_t SCUShort
Definition: SCTypes.h:66
uint8_t SCUByte
Definition: SCTypes.h:60
Abstract implementation of the protocol SCSorter.
Definition: SCSorter.h:37
SCIndex indexOfLastObject
Definition: SCArray.h:176
Indexed collections protocol.
Definition: SCIndexedCollection.h:39
NSString * lastString
Definition: SCArray.h:157
float_t SCFloat
Definition: SCTypes.h:84
id firstObject
Definition: SCArray.h:133
Abstract collections class.
Definition: SCCollection.h:94
NSString * firstString
Definition: SCArray.h:139
SCArray * sortedArray
Definition: SCArray.h:100
SCArray * reversedArray
Definition: SCArray.h:120
NSNumber * lastNumber
Definition: SCArray.h:163
Array class.
Definition: SCArray.h:77
double_t SCDouble
Definition: SCTypes.h:90
Abstract parent class of the stream classes hierarchy.
Definition: SCStream.h:242
id lastObject
Definition: SCArray.h:151