jeffpc / nx01

testing
MIT License
1 stars 0 forks source link

finish implementing nvclock_cmp*() #5

Closed jeffpc closed 9 years ago

jeffpc commented 9 years ago

We already need these functions.

nvclock_cmp() compares two vector clocks: returning NVC_LT, NVC_EQ, NVC_GT, NVC_DIV depending on whether the first argument is less than, equal to, greater than the second, or if the two clocks diverged and therefore neither is an ancestor of the other.

nvclock_cmp_total() returns -1, 0, +1 if the first arg is less than, equal to, or greater than the second. If the two vector clocks have diverged (nvclock_cmp() would return NVC_DIV), then nvclock_cmp_total() returns either -1 or +1 (but is consisent!). This provides a total ordering of vector clocks. This is useful as a comparator callback for avl_create() etc.

jeffpc commented 9 years ago

All that's left to do is implementing nvclock_cmp_total().