MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / SIArray_ContainsValue

Function SIArray_ContainsValue

src/datatypes/array.c:67–82  ·  view source on GitHub ↗

* @brief Returns true if the array contains an element equals to 'value' * @param siarray: array * @param value: value to search for * @param comparedNull: indicate if there was a null comparison during the array scan * @retval a boolean indicating whether value was found in siarray */

Source from the content-addressed store, hash-verified

65 * @retval a boolean indicating whether value was found in siarray
66 */
67bool SIArray_ContainsValue(SIValue siarray, SIValue value, bool *comparedNull) {
68 // indicate if there was a null comparison during the array scan
69 if(comparedNull) *comparedNull = false;
70 uint array_len = SIArray_Length(siarray);
71 for(uint i = 0; i < array_len; i++) {
72 int disjointOrNull = 0;
73 SIValue elem = siarray.array[i];
74 int compareValue = SIValue_Compare(elem, value, &disjointOrNull);
75 if(disjointOrNull == COMPARED_NULL) {
76 if(comparedNull) *comparedNull = true;
77 continue;
78 }
79 if(compareValue == 0) return true;
80 }
81 return false;
82}
83
84bool SIArray_AllOfType(SIValue siarray, SIType t) {
85 uint array_len = SIArray_Length(siarray);

Callers 3

AR_INFunction · 0.85
AR_INSERTFunction · 0.85
_AR_NodeDegreeFunction · 0.85

Calls 2

SIArray_LengthFunction · 0.85
SIValue_CompareFunction · 0.85

Tested by

no test coverage detected