Documentation ¶
Overview ¶
Package timeline defines the basic types of a timeline.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var MaxTime = time.Unix(1<<63-1-unixToInternal, 999999999)
MaxTime is the largest time after MinTime where durations don't overflow.
var MinTime = time.Time{}
MinTime is a sensible time for which timeline operations make sense. Timelines compare times to order them, these values prevent overflows during these operations.
Functions ¶
func Bound ¶
Bound returns the first and last event time of tl, if they exist.
If tl implements BoundTl, Bound calls tl.Bound. Otherwise Bound attempts to find the first and last events by calling Previous and Next using MinTime and MaxTime.
func Empty ¶
Empty returns true if there are no events in the timeline.
If tl implements EmptyTL, Empty calls tl.Empty. Otherwise Empty uses Bound to check for existence.
func EqualExplain ¶
EqualExplain compares two TLs for equality, returning a reason if they aren't equal.
Types ¶
type AddTL ¶
type AddTL interface { TL // Add adds the given entries to this TL at the time specified by t. Add(t time.Time, entries ...interface{}) }
AddTL is a TL with an Add method.
Add does not have a fallback mechanism, so no Add utility function exists for this feature. To add to a TL, explicitly cast the TL to an AddTL and call Add directly.
Example ¶
tl := writableTL() if wtl, ok := tl.(AddTL); ok { wtl.Add(time.Now(), entries...) }
Output:
type BoundTL ¶
type BoundTL interface { TL // Bound returns the first and last event time, if they exist. Bound() (first, last time.Time, exists bool) }
BoundTL is a TL with a Bound method.
type EmptyTL ¶
type EmptyTL interface { TL // Empty return true if there are no event in the timeline. Empty() bool }
EmptyTL is a TL with an Empty method.
type RemoveTL ¶
type RemoveTL interface { TL // Remove removes the entries from the TL at the time specified by t. Remove(t time.Time, entries ...interface{}) }
RemoveTL is a TL with a Remove method.
Remove does not have a fallback mechanism, so no Remove utility function exists for this feature. To remove from a TL, explicitly cast the TL to a RemoveTL and call Remove directly.
Example ¶
tl := writableTL() if wtl, ok := tl.(RemoveTL); ok { wtl.Remove(time.Unix(1000, 0), entries...) }
Output:
type SliceTL ¶
type SliceTL interface { TL // Slice returns a TL containing only events >=from and <to. Slice(from, to time.Time) TL }
SliceTL is a TL with a Slice method.
type TL ¶
type TL interface { // At returns all the events at the specific time. At(t time.Time) []interface{} // Previous returns the newest time with events < t on this TL. Previous(t time.Time) (previous time.Time, exists bool) // Next returns the oldest time with events > t on this TL. Next(t time.Time) (next time.Time, exists bool) }
TL implements an ordered set of events, a timeline.
func Filter ¶
Filter returns a TL that only includes entries where MatchFunc returns true.
If tl is a FilterTL, Filter returns tl.Filter. Otherwise Filter returns a new TL that acts as if no entries exist that MatchFunc returns false for.
func FromSlice ¶
FromSlice creates a TL using a []Ater. This will sort s in place by the results of calling s[i].At().
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package skiplisttl provides a skip list based implementation of timeline.TL.
|
Package skiplisttl provides a skip list based implementation of timeline.TL. |