| 11 | #include "../../util/rmalloc.h" |
| 12 | |
| 13 | static bool _removeEntryFromMultiValArr |
| 14 | ( |
| 15 | uint64_t **entries, // multi-value array |
| 16 | uint64_t entry // element to remove output new value |
| 17 | ) { |
| 18 | ASSERT(*entries != NULL); |
| 19 | |
| 20 | uint i = 0; |
| 21 | uint n = array_len(*entries); |
| 22 | |
| 23 | // search for entry |
| 24 | for(; i < n; i++) { |
| 25 | if((*entries)[i] == entry) { |
| 26 | break; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | ASSERT(i < n); |
| 31 | |
| 32 | // remove located entry |
| 33 | // migrate last element and reduce array size |
| 34 | array_del_fast(*entries, i); |
| 35 | |
| 36 | // incase we're left with a single entry revert back to scalar |
| 37 | if(array_len(*entries) == 1) { |
| 38 | entry = (*entries)[0]; |
| 39 | array_free(*entries); |
| 40 | *entries = (uint64_t *)entry; |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | static GrB_Info _removeElementMultiVal |
| 48 | ( |
no test coverage detected