Snippet. Vala. Compare Two Arrays, if EqualThis Vala snippet provides an utility function array_equals, which will compare two arrays. Function: array_equalsWith the function array_equals (see bellow) you can find out, if two arrays are equal to one another. The arrays will be considered equal, if they contain the same number of elements and all corresponding pairs of elements are equal. In other words, the two arrays will be considered equal, if they contain the same elements in the same order. Also the two arrays will be considered equal if both are null. //======================== START OF FUNCTION ==========================// // FUNCTION: array_equals // //=====================================================================// /** * Returns true if the two specified arrays are equal to one another. * Two arrays are considered equal if both arrays contain the same * number of elements, and all corresponding pairs of elements in * the two arrays are equal. In other words, two arrays are equal * if they contain the same elements in the same order. * Also, two array references are considered equal if both are null. * @return true if the two arrays are equal */ bool array_equals Use ExampleHow to use the function array_equals: // Compare arrays of integers int[] array_one = {5,2,1,4,5,3,7,9,8}; int[] array_two = {5,2,1,4,5,3,7,9,8}; bool result = array_equals Updated on: 21 Nov 2024 |
|