NewExecutionSegmentSequence validates the that the supplied execution segments are non-overlapping and without gaps. It will return a new execution segment sequence if that is true, and an error if it's not.
(segments ...*ExecutionSegment)
| 303 | // segments are non-overlapping and without gaps. It will return a new execution |
| 304 | // segment sequence if that is true, and an error if it's not. |
| 305 | func NewExecutionSegmentSequence(segments ...*ExecutionSegment) (ExecutionSegmentSequence, error) { |
| 306 | if len(segments) > 1 { |
| 307 | to := segments[0].to |
| 308 | for i, segment := range segments[1:] { |
| 309 | if segment.from.Cmp(to) != 0 { |
| 310 | return nil, fmt.Errorf( |
| 311 | "the start value %s of segment #%d must be equal to the end value of the previous one, but it is %s", |
| 312 | segment.from, i+1, to, |
| 313 | ) |
| 314 | } |
| 315 | to = segment.to |
| 316 | } |
| 317 | } |
| 318 | return ExecutionSegmentSequence(segments), nil |
| 319 | } |
| 320 | |
| 321 | // NewExecutionSegmentSequenceFromString parses strings of the format |
| 322 | // "r1,r2,r3,...,rn", which represents the sequences like (r1, r2], (r2, r3], |
searching dependent graphs…