Lines Matching +full:array +full:- +full:bounds
1 // Protocol Buffers - Google's data interchange format
3 // https://developers.google.com/protocol-buffers/
37 // protos can turn on -Wdirect-ivar-access without issues.
39 #pragma clang diagnostic ignored "-Wdirect-ivar-access"
50 //%PDDM-DEFINE VALIDATE_RANGE(INDEX, COUNT)
53 //% format:@"Index (%lu) beyond bounds (%lu)",
56 //%PDDM-DEFINE MAYBE_GROW_TO_SET_COUNT(NEW_COUNT)
61 //%PDDM-DEFINE SET_COUNT_AND_MAYBE_SHRINK(NEW_COUNT)
71 //%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE, FORMAT)
72 //%#pragma mark - NAME
74 //%@implementation GPB##NAME##Array {
83 //%+ (instancetype)array {
90 //% return [[(GPB##NAME##Array*)[self alloc] initWithValues:&value count:1] autorelease];
93 //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array {
94 //% return [[(GPB##NAME##Array*)[self alloc] initWithValueArray:array] autorelease];
101 //%- (instancetype)init {
107 //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array {
108 //% return [self initWithValues:array->_values count:array->_count];
111 //%- (instancetype)initWithValues:(const TYPE [])values count:(NSUInteger)count {
131 //%- (instancetype)initWithCapacity:(NSUInteger)count {
139 //%- (instancetype)copyWithZone:(NSZone *)zone {
140 //% return [[GPB##NAME##Array allocWithZone:zone] initWithValues:_values count:_count];
145 //%- (TYPE)valueAtIndex:(NSUInteger)index {
158 //%PDDM-DEFINE ARRAY_IMMUTABLE_CORE(NAME, TYPE, ACCESSOR_NAME, FORMAT)
159 //%- (void)dealloc {
167 //%- (BOOL)isEqual:(id)other {
171 //% if (![other isKindOfClass:[GPB##NAME##Array class]]) {
174 //% GPB##NAME##Array *otherArray = other;
175 //% return (_count == otherArray->_count
176 //% && memcmp(_values, otherArray->_values, (_count * sizeof(TYPE))) == 0);
179 //%- (NSUInteger)hash {
184 //%- (NSString *)description {
197 //%- (void)enumerate##ACCESSOR_NAME##ValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger i…
201 //%- (void)enumerate##ACCESSOR_NAME##ValuesWithOptions:(NSEnumerationOptions)opts
211 //% for (NSUInteger i = _count; i > 0; --i) {
212 //% block(_values[i - 1], (i - 1), &stop);
218 //%PDDM-DEFINE MUTATION_HOOK_None()
219 //%PDDM-DEFINE MUTATION_METHODS(NAME, TYPE, ACCESSOR_NAME, HOOK_1, HOOK_2)
220 //%- (void)add##ACCESSOR_NAME##Value:(TYPE)value {
224 //%- (void)add##ACCESSOR_NAME##Values:(const TYPE [])values count:(NSUInteger)count {
235 //%- (void)insert##ACCESSOR_NAME##Value:(TYPE)value atIndex:(NSUInteger)index {
241 //% memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(TYPE));
249 //%- (void)replaceValueAtIndex:(NSUInteger)index with##ACCESSOR_NAME##Value:(TYPE)value {
254 //%PDDM-DEFINE ARRAY_MUTABLE_CORE(NAME, TYPE, ACCESSOR_NAME, FORMAT)
255 //%- (void)internalResizeToCapacity:(NSUInteger)newCapacity {
269 //%- (void)add##ACCESSOR_NAME##ValuesFromArray:(GPB##NAME##Array *)array {
270 //% [self add##ACCESSOR_NAME##Values:array->_values count:array->_count];
273 //%- (void)removeValueAtIndex:(NSUInteger)index {
275 //% NSUInteger newCount = _count - 1;
277 //% memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(TYPE));
282 //%- (void)removeAll {
286 //%- (void)exchangeValueAtIndex:(NSUInteger)idx1
296 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Int32, int32_t, %d)
298 // clang-format off
300 #pragma mark - Int32
311 + (instancetype)array { class
321 + (instancetype)arrayWithValueArray:(GPBInt32Array *)array {
322 return [[(GPBInt32Array*)[self alloc] initWithValueArray:array] autorelease];
329 - (instancetype)init {
335 - (instancetype)initWithValueArray:(GPBInt32Array *)array {
336 return [self initWithValues:array->_values count:array->_count];
339 - (instancetype)initWithValues:(const int32_t [])values count:(NSUInteger)count {
359 - (instancetype)initWithCapacity:(NSUInteger)count {
367 - (instancetype)copyWithZone:(NSZone *)zone {
371 - (void)dealloc {
379 - (BOOL)isEqual:(id)other {
387 return (_count == otherArray->_count
388 && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) == 0);
391 - (NSUInteger)hash {
396 - (NSString *)description {
409 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))b…
413 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
423 for (NSUInteger i = _count; i > 0; --i) {
424 block(_values[i - 1], (i - 1), &stop);
430 - (int32_t)valueAtIndex:(NSUInteger)index {
433 format:@"Index (%lu) beyond bounds (%lu)",
439 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
451 - (void)addValue:(int32_t)value {
455 - (void)addValues:(const int32_t [])values count:(NSUInteger)count {
469 - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index {
472 format:@"Index (%lu) beyond bounds (%lu)",
482 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int32_t));
490 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value {
493 format:@"Index (%lu) beyond bounds (%lu)",
499 - (void)addValuesFromArray:(GPBInt32Array *)array {
500 [self addValues:array->_values count:array->_count];
503 - (void)removeValueAtIndex:(NSUInteger)index {
506 format:@"Index (%lu) beyond bounds (%lu)",
509 NSUInteger newCount = _count - 1;
511 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(int32_t));
519 - (void)removeAll {
526 - (void)exchangeValueAtIndex:(NSUInteger)idx1
530 format:@"Index (%lu) beyond bounds (%lu)",
535 format:@"Index (%lu) beyond bounds (%lu)",
545 // clang-format on
546 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t, %u)
548 // clang-format off
550 #pragma mark - UInt32
561 + (instancetype)array { class
571 + (instancetype)arrayWithValueArray:(GPBUInt32Array *)array {
572 return [[(GPBUInt32Array*)[self alloc] initWithValueArray:array] autorelease];
579 - (instancetype)init {
585 - (instancetype)initWithValueArray:(GPBUInt32Array *)array {
586 return [self initWithValues:array->_values count:array->_count];
589 - (instancetype)initWithValues:(const uint32_t [])values count:(NSUInteger)count {
609 - (instancetype)initWithCapacity:(NSUInteger)count {
617 - (instancetype)copyWithZone:(NSZone *)zone {
621 - (void)dealloc {
629 - (BOOL)isEqual:(id)other {
637 return (_count == otherArray->_count
638 && memcmp(_values, otherArray->_values, (_count * sizeof(uint32_t))) == 0);
641 - (NSUInteger)hash {
646 - (NSString *)description {
659 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))…
663 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
673 for (NSUInteger i = _count; i > 0; --i) {
674 block(_values[i - 1], (i - 1), &stop);
680 - (uint32_t)valueAtIndex:(NSUInteger)index {
683 format:@"Index (%lu) beyond bounds (%lu)",
689 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
701 - (void)addValue:(uint32_t)value {
705 - (void)addValues:(const uint32_t [])values count:(NSUInteger)count {
719 - (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index {
722 format:@"Index (%lu) beyond bounds (%lu)",
732 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(uint32_t));
740 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value {
743 format:@"Index (%lu) beyond bounds (%lu)",
749 - (void)addValuesFromArray:(GPBUInt32Array *)array {
750 [self addValues:array->_values count:array->_count];
753 - (void)removeValueAtIndex:(NSUInteger)index {
756 format:@"Index (%lu) beyond bounds (%lu)",
759 NSUInteger newCount = _count - 1;
761 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(uint32_t));
769 - (void)removeAll {
776 - (void)exchangeValueAtIndex:(NSUInteger)idx1
780 format:@"Index (%lu) beyond bounds (%lu)",
785 format:@"Index (%lu) beyond bounds (%lu)",
795 // clang-format on
796 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Int64, int64_t, %lld)
798 // clang-format off
800 #pragma mark - Int64
811 + (instancetype)array { class
821 + (instancetype)arrayWithValueArray:(GPBInt64Array *)array {
822 return [[(GPBInt64Array*)[self alloc] initWithValueArray:array] autorelease];
829 - (instancetype)init {
835 - (instancetype)initWithValueArray:(GPBInt64Array *)array {
836 return [self initWithValues:array->_values count:array->_count];
839 - (instancetype)initWithValues:(const int64_t [])values count:(NSUInteger)count {
859 - (instancetype)initWithCapacity:(NSUInteger)count {
867 - (instancetype)copyWithZone:(NSZone *)zone {
871 - (void)dealloc {
879 - (BOOL)isEqual:(id)other {
887 return (_count == otherArray->_count
888 && memcmp(_values, otherArray->_values, (_count * sizeof(int64_t))) == 0);
891 - (NSUInteger)hash {
896 - (NSString *)description {
909 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))b…
913 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
923 for (NSUInteger i = _count; i > 0; --i) {
924 block(_values[i - 1], (i - 1), &stop);
930 - (int64_t)valueAtIndex:(NSUInteger)index {
933 format:@"Index (%lu) beyond bounds (%lu)",
939 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
951 - (void)addValue:(int64_t)value {
955 - (void)addValues:(const int64_t [])values count:(NSUInteger)count {
969 - (void)insertValue:(int64_t)value atIndex:(NSUInteger)index {
972 format:@"Index (%lu) beyond bounds (%lu)",
982 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int64_t));
990 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value {
993 format:@"Index (%lu) beyond bounds (%lu)",
999 - (void)addValuesFromArray:(GPBInt64Array *)array {
1000 [self addValues:array->_values count:array->_count];
1003 - (void)removeValueAtIndex:(NSUInteger)index {
1006 format:@"Index (%lu) beyond bounds (%lu)",
1009 NSUInteger newCount = _count - 1;
1011 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(int64_t));
1019 - (void)removeAll {
1026 - (void)exchangeValueAtIndex:(NSUInteger)idx1
1030 format:@"Index (%lu) beyond bounds (%lu)",
1035 format:@"Index (%lu) beyond bounds (%lu)",
1045 // clang-format on
1046 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t, %llu)
1048 // clang-format off
1050 #pragma mark - UInt64
1061 + (instancetype)array { class
1071 + (instancetype)arrayWithValueArray:(GPBUInt64Array *)array {
1072 return [[(GPBUInt64Array*)[self alloc] initWithValueArray:array] autorelease];
1079 - (instancetype)init {
1085 - (instancetype)initWithValueArray:(GPBUInt64Array *)array {
1086 return [self initWithValues:array->_values count:array->_count];
1089 - (instancetype)initWithValues:(const uint64_t [])values count:(NSUInteger)count {
1109 - (instancetype)initWithCapacity:(NSUInteger)count {
1117 - (instancetype)copyWithZone:(NSZone *)zone {
1121 - (void)dealloc {
1129 - (BOOL)isEqual:(id)other {
1137 return (_count == otherArray->_count
1138 && memcmp(_values, otherArray->_values, (_count * sizeof(uint64_t))) == 0);
1141 - (NSUInteger)hash {
1146 - (NSString *)description {
1159 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))…
1163 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
1173 for (NSUInteger i = _count; i > 0; --i) {
1174 block(_values[i - 1], (i - 1), &stop);
1180 - (uint64_t)valueAtIndex:(NSUInteger)index {
1183 format:@"Index (%lu) beyond bounds (%lu)",
1189 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
1201 - (void)addValue:(uint64_t)value {
1205 - (void)addValues:(const uint64_t [])values count:(NSUInteger)count {
1219 - (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index {
1222 format:@"Index (%lu) beyond bounds (%lu)",
1232 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(uint64_t));
1240 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value {
1243 format:@"Index (%lu) beyond bounds (%lu)",
1249 - (void)addValuesFromArray:(GPBUInt64Array *)array {
1250 [self addValues:array->_values count:array->_count];
1253 - (void)removeValueAtIndex:(NSUInteger)index {
1256 format:@"Index (%lu) beyond bounds (%lu)",
1259 NSUInteger newCount = _count - 1;
1261 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(uint64_t));
1269 - (void)removeAll {
1276 - (void)exchangeValueAtIndex:(NSUInteger)idx1
1280 format:@"Index (%lu) beyond bounds (%lu)",
1285 format:@"Index (%lu) beyond bounds (%lu)",
1295 // clang-format on
1296 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Float, float, %f)
1298 // clang-format off
1300 #pragma mark - Float
1311 + (instancetype)array { class
1321 + (instancetype)arrayWithValueArray:(GPBFloatArray *)array {
1322 return [[(GPBFloatArray*)[self alloc] initWithValueArray:array] autorelease];
1329 - (instancetype)init {
1335 - (instancetype)initWithValueArray:(GPBFloatArray *)array {
1336 return [self initWithValues:array->_values count:array->_count];
1339 - (instancetype)initWithValues:(const float [])values count:(NSUInteger)count {
1359 - (instancetype)initWithCapacity:(NSUInteger)count {
1367 - (instancetype)copyWithZone:(NSZone *)zone {
1371 - (void)dealloc {
1379 - (BOOL)isEqual:(id)other {
1387 return (_count == otherArray->_count
1388 && memcmp(_values, otherArray->_values, (_count * sizeof(float))) == 0);
1391 - (NSUInteger)hash {
1396 - (NSString *)description {
1409 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))blo…
1413 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
1423 for (NSUInteger i = _count; i > 0; --i) {
1424 block(_values[i - 1], (i - 1), &stop);
1430 - (float)valueAtIndex:(NSUInteger)index {
1433 format:@"Index (%lu) beyond bounds (%lu)",
1439 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
1451 - (void)addValue:(float)value {
1455 - (void)addValues:(const float [])values count:(NSUInteger)count {
1469 - (void)insertValue:(float)value atIndex:(NSUInteger)index {
1472 format:@"Index (%lu) beyond bounds (%lu)",
1482 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(float));
1490 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value {
1493 format:@"Index (%lu) beyond bounds (%lu)",
1499 - (void)addValuesFromArray:(GPBFloatArray *)array {
1500 [self addValues:array->_values count:array->_count];
1503 - (void)removeValueAtIndex:(NSUInteger)index {
1506 format:@"Index (%lu) beyond bounds (%lu)",
1509 NSUInteger newCount = _count - 1;
1511 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(float));
1519 - (void)removeAll {
1526 - (void)exchangeValueAtIndex:(NSUInteger)idx1
1530 format:@"Index (%lu) beyond bounds (%lu)",
1535 format:@"Index (%lu) beyond bounds (%lu)",
1545 // clang-format on
1546 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Double, double, %lf)
1548 // clang-format off
1550 #pragma mark - Double
1561 + (instancetype)array { class
1571 + (instancetype)arrayWithValueArray:(GPBDoubleArray *)array {
1572 return [[(GPBDoubleArray*)[self alloc] initWithValueArray:array] autorelease];
1579 - (instancetype)init {
1585 - (instancetype)initWithValueArray:(GPBDoubleArray *)array {
1586 return [self initWithValues:array->_values count:array->_count];
1589 - (instancetype)initWithValues:(const double [])values count:(NSUInteger)count {
1609 - (instancetype)initWithCapacity:(NSUInteger)count {
1617 - (instancetype)copyWithZone:(NSZone *)zone {
1621 - (void)dealloc {
1629 - (BOOL)isEqual:(id)other {
1637 return (_count == otherArray->_count
1638 && memcmp(_values, otherArray->_values, (_count * sizeof(double))) == 0);
1641 - (NSUInteger)hash {
1646 - (NSString *)description {
1659 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))bl…
1663 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
1673 for (NSUInteger i = _count; i > 0; --i) {
1674 block(_values[i - 1], (i - 1), &stop);
1680 - (double)valueAtIndex:(NSUInteger)index {
1683 format:@"Index (%lu) beyond bounds (%lu)",
1689 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
1701 - (void)addValue:(double)value {
1705 - (void)addValues:(const double [])values count:(NSUInteger)count {
1719 - (void)insertValue:(double)value atIndex:(NSUInteger)index {
1722 format:@"Index (%lu) beyond bounds (%lu)",
1732 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(double));
1740 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value {
1743 format:@"Index (%lu) beyond bounds (%lu)",
1749 - (void)addValuesFromArray:(GPBDoubleArray *)array {
1750 [self addValues:array->_values count:array->_count];
1753 - (void)removeValueAtIndex:(NSUInteger)index {
1756 format:@"Index (%lu) beyond bounds (%lu)",
1759 NSUInteger newCount = _count - 1;
1761 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(double));
1769 - (void)removeAll {
1776 - (void)exchangeValueAtIndex:(NSUInteger)idx1
1780 format:@"Index (%lu) beyond bounds (%lu)",
1785 format:@"Index (%lu) beyond bounds (%lu)",
1795 // clang-format on
1796 //%PDDM-EXPAND ARRAY_INTERFACE_SIMPLE(Bool, BOOL, %d)
1798 // clang-format off
1800 #pragma mark - Bool
1811 + (instancetype)array { class
1821 + (instancetype)arrayWithValueArray:(GPBBoolArray *)array {
1822 return [[(GPBBoolArray*)[self alloc] initWithValueArray:array] autorelease];
1829 - (instancetype)init {
1835 - (instancetype)initWithValueArray:(GPBBoolArray *)array {
1836 return [self initWithValues:array->_values count:array->_count];
1839 - (instancetype)initWithValues:(const BOOL [])values count:(NSUInteger)count {
1859 - (instancetype)initWithCapacity:(NSUInteger)count {
1867 - (instancetype)copyWithZone:(NSZone *)zone {
1871 - (void)dealloc {
1879 - (BOOL)isEqual:(id)other {
1887 return (_count == otherArray->_count
1888 && memcmp(_values, otherArray->_values, (_count * sizeof(BOOL))) == 0);
1891 - (NSUInteger)hash {
1896 - (NSString *)description {
1909 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))bloc…
1913 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
1923 for (NSUInteger i = _count; i > 0; --i) {
1924 block(_values[i - 1], (i - 1), &stop);
1930 - (BOOL)valueAtIndex:(NSUInteger)index {
1933 format:@"Index (%lu) beyond bounds (%lu)",
1939 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
1951 - (void)addValue:(BOOL)value {
1955 - (void)addValues:(const BOOL [])values count:(NSUInteger)count {
1969 - (void)insertValue:(BOOL)value atIndex:(NSUInteger)index {
1972 format:@"Index (%lu) beyond bounds (%lu)",
1982 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(BOOL));
1990 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value {
1993 format:@"Index (%lu) beyond bounds (%lu)",
1999 - (void)addValuesFromArray:(GPBBoolArray *)array {
2000 [self addValues:array->_values count:array->_count];
2003 - (void)removeValueAtIndex:(NSUInteger)index {
2006 format:@"Index (%lu) beyond bounds (%lu)",
2009 NSUInteger newCount = _count - 1;
2011 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(BOOL));
2019 - (void)removeAll {
2026 - (void)exchangeValueAtIndex:(NSUInteger)idx1
2030 format:@"Index (%lu) beyond bounds (%lu)",
2035 format:@"Index (%lu) beyond bounds (%lu)",
2045 // clang-format on
2046 //%PDDM-EXPAND-END (7 expansions)
2048 #pragma mark - Enum
2061 + (instancetype)array { class
2076 + (instancetype)arrayWithValueArray:(GPBEnumArray *)array {
2077 return [[(GPBEnumArray*)[self alloc] initWithValueArray:array] autorelease];
2085 - (instancetype)init {
2089 - (instancetype)initWithValueArray:(GPBEnumArray *)array {
2090 return [self initWithValidationFunction:array->_validationFunc
2091 rawValues:array->_values
2092 count:array->_count];
2095 - (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func {
2103 - (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func
2125 - (instancetype)initWithValidationFunction:(GPBEnumValidationFunc)func
2134 - (instancetype)copyWithZone:(NSZone *)zone {
2141 //%PDDM-EXPAND ARRAY_IMMUTABLE_CORE(Enum, int32_t, Raw, %d)
2143 // clang-format off
2145 - (void)dealloc {
2153 - (BOOL)isEqual:(id)other {
2161 return (_count == otherArray->_count
2162 && memcmp(_values, otherArray->_values, (_count * sizeof(int32_t))) == 0);
2165 - (NSUInteger)hash {
2170 - (NSString *)description {
2183 - (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop…
2187 - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
2197 for (NSUInteger i = _count; i > 0; --i) {
2198 block(_values[i - 1], (i - 1), &stop);
2203 // clang-format on
2204 //%PDDM-EXPAND-END ARRAY_IMMUTABLE_CORE(Enum, int32_t, Raw, %d)
2206 - (int32_t)valueAtIndex:(NSUInteger)index {
2207 //%PDDM-EXPAND VALIDATE_RANGE(index, _count)
2209 // clang-format off
2213 format:@"Index (%lu) beyond bounds (%lu)",
2216 // clang-format on
2217 //%PDDM-EXPAND-END VALIDATE_RANGE(index, _count)
2225 - (int32_t)rawValueAtIndex:(NSUInteger)index {
2226 //%PDDM-EXPAND VALIDATE_RANGE(index, _count)
2228 // clang-format off
2232 format:@"Index (%lu) beyond bounds (%lu)",
2235 // clang-format on
2236 //%PDDM-EXPAND-END VALIDATE_RANGE(index, _count)
2240 - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))b…
2244 - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
2262 int32_t *scan = end + (_count - 1);
2263 for (NSUInteger i = (_count - 1); scan >= end; --i, --scan) {
2274 //%PDDM-EXPAND ARRAY_MUTABLE_CORE(Enum, int32_t, Raw, %d)
2276 // clang-format off
2278 - (void)internalResizeToCapacity:(NSUInteger)newCapacity {
2290 - (void)addRawValue:(int32_t)value {
2294 - (void)addRawValues:(const int32_t [])values count:(NSUInteger)count {
2308 - (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index {
2311 format:@"Index (%lu) beyond bounds (%lu)",
2321 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int32_t));
2329 - (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value {
2332 format:@"Index (%lu) beyond bounds (%lu)",
2338 - (void)addRawValuesFromArray:(GPBEnumArray *)array {
2339 [self addRawValues:array->_values count:array->_count];
2342 - (void)removeValueAtIndex:(NSUInteger)index {
2345 format:@"Index (%lu) beyond bounds (%lu)",
2348 NSUInteger newCount = _count - 1;
2350 memmove(&_values[index], &_values[index + 1], (newCount - index) * sizeof(int32_t));
2358 - (void)removeAll {
2365 - (void)exchangeValueAtIndex:(NSUInteger)idx1
2369 format:@"Index (%lu) beyond bounds (%lu)",
2374 format:@"Index (%lu) beyond bounds (%lu)",
2382 // clang-format on
2383 //%PDDM-EXPAND MUTATION_METHODS(Enum, int32_t, , EnumValidationList, EnumValidationOne)
2385 // clang-format off
2387 - (void)addValue:(int32_t)value {
2391 - (void)addValues:(const int32_t [])values count:(NSUInteger)count {
2413 - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index {
2416 format:@"Index (%lu) beyond bounds (%lu)",
2431 memmove(&_values[index + 1], &_values[index], (initialCount - index) * sizeof(int32_t));
2439 - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value {
2442 format:@"Index (%lu) beyond bounds (%lu)",
2452 // clang-format on
2453 //%PDDM-EXPAND-END (2 expansions)
2455 //%PDDM-DEFINE MUTATION_HOOK_EnumValidationList()
2465 //%PDDM-DEFINE MUTATION_HOOK_EnumValidationOne()
2475 #pragma mark - NSArray Subclass
2481 - (void)dealloc {
2491 - (NSUInteger)count {
2495 - (id)objectAtIndex:(NSUInteger)idx {
2504 - (void)insertObject:(id)anObject atIndex:(NSUInteger)idx {
2515 - (void)removeObject:(id)anObject {
2519 - (void)removeObjectAtIndex:(NSUInteger)idx {
2523 - (void)addObject:(id)anObject {
2534 - (void)removeLastObject {
2538 - (void)replaceObjectAtIndex:(NSUInteger)idx withObject:(id)anObject {
2544 - (id)copyWithZone:(NSZone *)zone {
2551 - (id)mutableCopyWithZone:(NSZone *)zone {
2558 - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
2564 - (void)enumerateObjectsUsingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block {
2568 - (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts