MCPcopy Create free account
hub / github.com/GJDuck/e9patch / setCompare

Function setCompare

src/e9tool/e9action.cpp:1870–1893  ·  view source on GitHub ↗

* Set comparison. */

Source from the content-addressed store, hash-verified

1868 * Set comparison.
1869 */
1870static int setCompare(const MatchVal *set1, const MatchVal *set2)
1871{
1872 const MatchVal *vals1 = set1->vals, *vals2 = set2->vals;
1873 const MatchVal *min1 = nullptr, *min2 = nullptr;
1874 for (size_t i = 0; vals1[i].type != MATCH_TYPE_UNDEFINED; i++)
1875 {
1876 if (isMember(&vals1[i], set2))
1877 continue;
1878 if (min1 == nullptr || vals1[i] < *min1)
1879 min1 = &vals1[i];
1880 }
1881 for (size_t i = 0; vals2[i].type != MATCH_TYPE_UNDEFINED; i++)
1882 {
1883 if (isMember(&vals2[i], set1))
1884 continue;
1885 if (min2 == nullptr || vals2[i] < *min2)
1886 min2 = &vals2[i];
1887 }
1888 if (min1 == nullptr)
1889 return (min2 == nullptr? 0: 1);
1890 else if (min2 == nullptr)
1891 return -1;
1892 return (*min1 < *min2? -1: 1);
1893}
1894
1895/*
1896 * Value comparison.

Callers 1

compareMethod · 0.85

Calls 1

isMemberFunction · 0.85

Tested by

no test coverage detected