equal
deleted
inserted
replaced
396 |
396 |
397 |
397 |
398 /* Search for a datatype inside a candidate_datatypes list. |
398 /* Search for a datatype inside a candidate_datatypes list. |
399 * Returns: position of datatype in the list, or -1 if not found. |
399 * Returns: position of datatype in the list, or -1 if not found. |
400 */ |
400 */ |
401 int search_in_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> candidate_datatypes) { |
401 int search_in_candidate_datatype_list(symbol_c *datatype, const std::vector <symbol_c *> &candidate_datatypes) { |
402 if (NULL == datatype) |
402 if (NULL == datatype) |
403 return -1; |
403 return -1; |
404 |
404 |
405 for(unsigned int i = 0; i < candidate_datatypes.size(); i++) |
405 for(unsigned int i = 0; i < candidate_datatypes.size(); i++) |
406 if (is_type_equal(datatype, candidate_datatypes[i])) |
406 if (is_type_equal(datatype, candidate_datatypes[i])) |
411 |
411 |
412 /* Remove a datatype inside a candidate_datatypes list. |
412 /* Remove a datatype inside a candidate_datatypes list. |
413 * Returns: If successful it returns true, false otherwise. |
413 * Returns: If successful it returns true, false otherwise. |
414 */ |
414 */ |
415 bool remove_from_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> &candidate_datatypes) { |
415 bool remove_from_candidate_datatype_list(symbol_c *datatype, std::vector <symbol_c *> &candidate_datatypes) { |
416 unsigned int ofs; |
416 int pos = search_in_candidate_datatype_list(datatype, candidate_datatypes); |
417 if (NULL == datatype) |
417 if (pos < 0) |
418 return false; |
418 return false; |
419 for(ofs = 0; ofs < candidate_datatypes.size(); ofs++) |
419 |
420 if (is_type_equal(datatype, candidate_datatypes[ofs])) |
420 candidate_datatypes.erase(candidate_datatypes.begin() + pos); |
421 break; |
421 return true; |
422 if (ofs < candidate_datatypes.size()) { |
|
423 candidate_datatypes.erase(candidate_datatypes.begin() + ofs); |
|
424 return true; |
|
425 } |
|
426 return false; |
|
427 } |
422 } |
428 |
423 |
429 |
424 |
430 |
425 |
431 /* Intersect two candidate_datatype_lists. |
426 /* Intersect two candidate_datatype_lists. |