Documentation
¶
Overview ¶
Package timebox implements functions to manage slots. A slot in this package is any tuple of a name, a start time and a duration. Slots can be combined into sets. Sets can be split into non-overlapping sets of slots.
Index ¶
- type Set
- func (s *Set) Add(slot *Slot)
- func (s *Set) All(f func(*Slot) bool) bool
- func (s *Set) Any(f func(*Slot) bool) bool
- func (s *Set) Contains(t time.Time) bool
- func (s *Set) Find(f func(*Slot) bool) []*Slot
- func (s *Set) Overlaps(slot *Slot) bool
- func (s *Set) Slots() []*Slot
- func (s *Set) SplitLinear() []*Set
- type Slot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a container with zero or more slots in it. Slots in a set may overlap each other. You can use the set to calculate lanes from the slots inside.
func (*Set) Add ¶
Add adds a new slot to a set. The slot is passed as a pointer that is stored in the set, so be aware that later changes to the slot affect the set.
func (*Set) Find ¶
Find returns a slice of all slots in the set satisfying f(slot), or an empty slice if none do. Be aware that any changes to the returned slots affect the set.
func (*Set) Slots ¶
Slots returns a slice of the slots in a set. Be aware that changes to the returned slots affect the set.
func (*Set) SplitLinear ¶
SplitLinear distributes the slots in the set to multiple sets in a way that ensures that no set contains multiple overlapping slots.
type Slot ¶
type Slot struct {
// contains filtered or unexported fields
}
Slot is a tuple of a name, a start time and a duration.
func NewSlotFromTimes ¶
NewSlotFromTimes creates a new slot from a name, a start time and an end time. The end time is not contained in the slot.
func (*Slot) Contains ¶
Contains returns whether a time is in a slot. Note that the start time of a slot is contained by it, but not the end time.