@@ -188,164 +188,133 @@ size_t _algo_count_varg(input_iterator_t it_first, input_iterator_t it_last, va_
188
188
/**
189
189
* Searches for the first subsequence in a range that of a specified number of elements having a particular value.
190
190
*/
191
- forward_iterator_t _algo_search_n (
192
- forward_iterator_t t_first , forward_iterator_t t_last ,
193
- size_t t_count , ...)
191
+ forward_iterator_t _algo_search_n (forward_iterator_t it_first , forward_iterator_t it_last , size_t t_count , ...)
194
192
{
195
- forward_iterator_t t_iter ;
193
+ forward_iterator_t it_iter ;
196
194
va_list val_elemlist ;
197
195
198
196
va_start (val_elemlist , t_count );
199
- t_iter = _algo_search_n_if_varg (t_first , t_last , t_count ,
200
- _fun_get_binary (t_first , _EQUAL_FUN ), val_elemlist );
197
+ it_iter = _algo_search_n_if_varg (it_first , it_last , t_count , _fun_get_binary (it_first , _EQUAL_FUN ), val_elemlist );
201
198
va_end (val_elemlist );
202
199
203
- return t_iter ;
200
+ return it_iter ;
204
201
}
205
202
206
203
/**
207
204
* Searches for the first subsequence in a range that of a specified number of elements having a relation to that value as specified by a binary predicate.
208
205
*/
209
206
forward_iterator_t _algo_search_n_if (
210
- forward_iterator_t t_first , forward_iterator_t t_last ,
211
- size_t t_count , binary_function_t t_binary_op , ...)
207
+ forward_iterator_t it_first , forward_iterator_t it_last , size_t t_count , binary_function_t bfun_op , ...)
212
208
{
213
- forward_iterator_t t_iter ;
209
+ forward_iterator_t it_iter ;
214
210
va_list val_elemlist ;
215
211
216
- va_start (val_elemlist , t_binary_op );
217
- t_iter = _algo_search_n_if_varg (
218
- t_first , t_last , t_count , t_binary_op , val_elemlist );
212
+ va_start (val_elemlist , bfun_op );
213
+ it_iter = _algo_search_n_if_varg (it_first , it_last , t_count , bfun_op , val_elemlist );
219
214
va_end (val_elemlist );
220
215
221
- return t_iter ;
216
+ return it_iter ;
222
217
}
223
218
224
219
/**
225
220
* Searches for the first subsequence in a range that of a specified number of elements having a relation to that value as specified by a binary predicate.
226
221
*/
227
222
forward_iterator_t _algo_search_n_if_varg (
228
- forward_iterator_t t_first , forward_iterator_t t_last ,
229
- size_t t_count , binary_function_t t_binary_op , va_list val_elemlist )
223
+ forward_iterator_t it_first , forward_iterator_t it_last , size_t t_count , binary_function_t bfun_op , va_list val_elemlist )
230
224
{
231
225
void * pv_value = NULL ;
232
- bool_t t_result = false;
233
- bool_t t_less = false;
234
- bool_t t_greater = false;
235
- iterator_t t_index ;
236
- size_t t_i = 0 ;
226
+ bool_t b_result = false;
227
+ bool_t b_less = false;
228
+ bool_t b_greater = false;
229
+ iterator_t it_index ;
230
+ size_t i = 0 ;
237
231
238
- assert (_iterator_valid_range (t_first , t_last , _FORWARD_ITERATOR ));
232
+ assert (_iterator_valid_range (it_first , it_last , _FORWARD_ITERATOR ));
239
233
240
- if (t_count == 0 )
241
- {
242
- return t_last ;
234
+ if (t_count == 0 ) {
235
+ return it_first ;
243
236
}
244
237
245
- if (t_binary_op == NULL )
246
- {
247
- t_binary_op = _fun_get_binary (t_first , _EQUAL_FUN );
238
+ if (bfun_op == NULL ) {
239
+ bfun_op = _fun_get_binary (it_first , _EQUAL_FUN );
248
240
}
249
241
250
- pv_value = _iterator_allocate_init_elem (t_first );
251
- _type_get_varg_value (_iterator_get_typeinfo (t_first ), val_elemlist , pv_value );
252
-
253
- if (t_binary_op == fun_default_binary )
254
- {
255
- t_binary_op = _fun_get_binary (t_first , _LESS_FUN );
256
- for (; !iterator_equal (t_first , t_last ); t_first = iterator_next (t_first ))
257
- {
258
- (* t_binary_op )(iterator_get_pointer (t_first ), pv_value , & t_less );
259
- if (t_less )
260
- {
242
+ pv_value = _iterator_allocate_init_elem (it_first );
243
+ _type_get_varg_value (_iterator_get_typeinfo (it_first ), val_elemlist , pv_value );
244
+
245
+ if (bfun_op == fun_default_binary ) {
246
+ bfun_op = _fun_get_binary (it_first , _LESS_FUN );
247
+ for (; !iterator_equal (it_first , it_last ); it_first = iterator_next (it_first )) {
248
+ (* bfun_op )(iterator_get_pointer (it_first ), pv_value , & b_less );
249
+ if (b_less ) {
261
250
continue ;
262
251
}
263
- (* t_binary_op )(pv_value , iterator_get_pointer (t_first ), & t_greater );
264
- if (t_greater )
265
- {
252
+ (* bfun_op )(pv_value , iterator_get_pointer (it_first ), & b_greater );
253
+ if (b_greater ) {
266
254
continue ;
267
255
}
268
256
269
- for (t_i = 1 , t_index = t_first , t_index = iterator_next (t_index );
270
- t_i < t_count && !iterator_equal (t_index , t_last );
271
- ++ t_i , t_index = iterator_next (t_index ))
272
- {
273
- (* t_binary_op )(iterator_get_pointer (t_index ), pv_value , & t_less );
274
- if (t_less )
275
- {
257
+ for (i = 1 , it_index = iterator_next (it_first );
258
+ i < t_count && !iterator_equal (it_index , it_last );
259
+ ++ i , it_index = iterator_next (it_index )) {
260
+ (* bfun_op )(iterator_get_pointer (it_index ), pv_value , & b_less );
261
+ if (b_less ) {
276
262
break ;
277
263
}
278
- (* t_binary_op )(pv_value , iterator_get_pointer (t_index ), & t_greater );
279
- if (t_greater )
280
- {
264
+ (* bfun_op )(pv_value , iterator_get_pointer (it_index ), & b_greater );
265
+ if (b_greater ) {
281
266
break ;
282
267
}
283
268
}
284
269
285
- if (t_i == t_count )
286
- {
270
+ if (i == t_count ) {
287
271
break ;
288
272
}
289
273
}
290
- }
291
- else
292
- {
293
- if (strncmp (_iterator_get_typebasename (t_first ), _C_STRING_TYPE , _TYPE_NAME_SIZE ) == 0 )
294
- {
295
- for (; !iterator_equal (t_first , t_last ); t_first = iterator_next (t_first ))
296
- {
297
- (* t_binary_op )(iterator_get_pointer (t_first ), string_c_str ((string_t * )pv_value ), & t_result );
298
- if (t_result )
299
- {
300
- for (t_i = 1 , t_index = t_first , t_index = iterator_next (t_index );
301
- t_i < t_count && !iterator_equal (t_index , t_last );
302
- ++ t_i , t_index = iterator_next (t_index ))
303
- {
304
- (* t_binary_op )(iterator_get_pointer (t_index ), string_c_str ((string_t * )pv_value ), & t_result );
305
- if (!t_result )
306
- {
274
+ } else {
275
+ if (strncmp (_iterator_get_typebasename (it_first ), _C_STRING_TYPE , _TYPE_NAME_SIZE ) == 0 ) {
276
+ for (; !iterator_equal (it_first , it_last ); it_first = iterator_next (it_first )) {
277
+ (* bfun_op )(iterator_get_pointer (it_first ), string_c_str ((string_t * )pv_value ), & b_result );
278
+ if (b_result ) {
279
+ for (i = 1 , it_index = iterator_next (it_first );
280
+ i < t_count && !iterator_equal (it_index , it_last );
281
+ ++ i , it_index = iterator_next (it_index )) {
282
+ (* bfun_op )(iterator_get_pointer (it_index ), string_c_str ((string_t * )pv_value ), & b_result );
283
+ if (!b_result ) {
307
284
break ;
308
285
}
309
286
}
310
287
311
- if (t_i == t_count )
312
- {
288
+ if (i == t_count ) {
313
289
break ;
314
290
}
315
291
}
316
292
}
317
- }
318
- else
319
- {
320
- for (; !iterator_equal (t_first , t_last ); t_first = iterator_next (t_first ))
321
- {
322
- (* t_binary_op )(iterator_get_pointer (t_first ), pv_value , & t_result );
323
- if (t_result )
324
- {
325
- for (t_i = 1 , t_index = t_first , t_index = iterator_next (t_index );
326
- t_i < t_count && !iterator_equal (t_index , t_last );
327
- ++ t_i , t_index = iterator_next (t_index ))
328
- {
329
- (* t_binary_op )(iterator_get_pointer (t_index ), pv_value , & t_result );
330
- if (!t_result )
331
- {
293
+ } else {
294
+ for (; !iterator_equal (it_first , it_last ); it_first = iterator_next (it_first )) {
295
+ (* bfun_op )(iterator_get_pointer (it_first ), pv_value , & b_result );
296
+ if (b_result ) {
297
+ for (i = 1 , it_index = iterator_next (it_first );
298
+ i < t_count && !iterator_equal (it_index , it_last );
299
+ ++ i , it_index = iterator_next (it_index )) {
300
+ (* bfun_op )(iterator_get_pointer (it_index ), pv_value , & b_result );
301
+ if (!b_result ) {
332
302
break ;
333
303
}
334
304
}
335
305
336
- if (t_i == t_count )
337
- {
306
+ if (i == t_count ) {
338
307
break ;
339
308
}
340
309
}
341
310
}
342
311
}
343
312
}
344
313
345
- _iterator_deallocate_destroy_elem (t_first , pv_value );
314
+ _iterator_deallocate_destroy_elem (it_first , pv_value );
346
315
pv_value = NULL ;
347
316
348
- return t_first ;
317
+ return it_first ;
349
318
}
350
319
351
320
/** eof **/
0 commit comments