Documentation
¶
Index ¶
- func IsInstant(a Span) bool
- func Within(a, b Span) bool
- type ByEnd
- type ByStart
- type IntersectionHandlerFunc
- type Span
- type Spans
- func (s Spans) Duration() time.Duration
- func (s Spans) Intersection() Spans
- func (s Spans) IntersectionBetween(b Spans) Spans
- func (s Spans) IntersectionBetweenWithHandler(candidates Spans, intersectHandlerFunc IntersectionHandlerFunc) Spans
- func (s Spans) IntersectionWithHandler(intersectHandlerFunc IntersectionHandlerFunc) Spans
- func (s Spans) String() string
- func (s Spans) Without(b Span) Spans
- func (s Spans) WithoutWithHandler(b Span, handlerFunc WithoutHandlerFunc) Spans
- type TimeSpan
- func (ts TimeSpan) Duration() time.Duration
- func (ts TimeSpan) End() time.Time
- func (ts *TimeSpan) MarshalBinary() ([]byte, error)
- func (ts TimeSpan) MarshalJSON() ([]byte, error)
- func (ts TimeSpan) Start() time.Time
- func (ts TimeSpan) String() string
- func (ts *TimeSpan) UnmarshalBinary(data []byte) error
- func (ts *TimeSpan) UnmarshalJSON(b []byte) (err error)
- type UnionHandlerFunc
- type WithoutHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IntersectionHandlerFunc ¶
type IntersectionHandlerFunc func(intersectingEvent1, intersectingEvent2, intersectionSpan Span) Span
IntersectionHandlerFunc is used by IntersectionWithHandler to allow for custom functionality when two spans intersect. It is passed the two spans that intersect, and span representing the intersection.
type Spans ¶
type Spans []Span
Spans represents a list of spans, on which other functions operate.
func Without ¶
Without returns a list of spans representing the spans of baseSpan not covered by intersector. It can return one Span element in Spans, if the intersector can overlap at the beginning or end of baseSpan (baseSpan.Start/End is moved to intersector.End/Start) or It returns two Span elements in Spans, if the intersector is within the baseSpan. this creates a Span baseSpan.Start->interseector.Start and intersector.End->baseSpan.End
func WithoutWithHandler ¶
func WithoutWithHandler(a, b Span, handlerFunc WithoutHandlerFunc) Spans
func (Spans) Intersection ¶
Intersection returns a list of Spans representing the overlaps between the contained spans. For example, given a list [A,B] where A and B overlap, a list [C] would be returned, with the span C covering the intersection of A and B.
func (Spans) IntersectionBetween ¶
IntersectionBetween returns the slice of spans representing the overlaps between the contained spans and a given set of spans.
func (Spans) IntersectionBetweenWithHandler ¶
func (s Spans) IntersectionBetweenWithHandler(candidates Spans, intersectHandlerFunc IntersectionHandlerFunc) Spans
IntersectionBetweenWithHandler returns a list of pointers to Spans representing the overlaps between the contained spans and a given set of spans. It calls intersectHandlerFunc for each pair of spans that are intersected.
func (Spans) IntersectionWithHandler ¶
func (s Spans) IntersectionWithHandler(intersectHandlerFunc IntersectionHandlerFunc) Spans
IntersectionWithHandler returns a list of Spans representing the overlaps between the contained spans. For example, given a list [A,B] where A and B overlap, a list [C] would be returned, with the span C covering the intersection of the A and B. The provided handler function is notified of the two spans that have been found to overlap, and the span representing the overlap.
func (Spans) WithoutWithHandler ¶
func (s Spans) WithoutWithHandler(b Span, handlerFunc WithoutHandlerFunc) Spans
type TimeSpan ¶
type TimeSpan struct {
// contains filtered or unexported fields
}
TimeSpan represents a simple span of time, with no additional properties. It should be constructed with NewEmpty.
func New ¶
New creates a span with a start and end time, with the types set to [] for instants and [) for spans.
func (*TimeSpan) MarshalBinary ¶ added in v2.0.3
func (TimeSpan) MarshalJSON ¶
MarshalJSON implements json.Marshal
func (*TimeSpan) UnmarshalBinary ¶ added in v2.0.3
func (*TimeSpan) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshal
type UnionHandlerFunc ¶
UnionHandlerFunc is used by UnionWithHandler to allow for custom functionality when two spans are merged. It is passed the two spans to be merged, and span which will result from the union.