The most significant value is TriggeredBy, unless it's zero, in which case use Seq. The tricky part is that "n" sorts after "n:m" for any nonzero m
(s2 SequenceID)
| 185 | // The most significant value is TriggeredBy, unless it's zero, in which case use Seq. |
| 186 | // The tricky part is that "n" sorts after "n:m" for any nonzero m |
| 187 | func (s SequenceID) Before(s2 SequenceID) bool { |
| 188 | // using SafeSequence for comparison, which takes the lower of LowSeq and Seq |
| 189 | if s.TriggeredBy == s2.TriggeredBy { |
| 190 | if s.SafeSequence() == s2.SafeSequence() { |
| 191 | // If both are equal, one sequence must be a non-zero LowSeq - sort those after the actual sequence. |
| 192 | return s.Seq < s2.Seq |
| 193 | } |
| 194 | return s.SafeSequence() < s2.SafeSequence() // the simple case: untriggered, or triggered by same sequence |
| 195 | } else if s.TriggeredBy == 0 { |
| 196 | return s.SafeSequence() < s2.TriggeredBy // s2 triggered but not s |
| 197 | } else if s2.TriggeredBy == 0 { |
| 198 | return s.TriggeredBy <= s2.SafeSequence() // s triggered but not s2 |
| 199 | } else { |
| 200 | return s.TriggeredBy < s2.TriggeredBy // both triggered, but by different sequences |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // Create a zero'd out since value (eg, initial since value) based on the sequence type |
| 205 | func CreateZeroSinceValue() SequenceID { |