Documentation
¶
Overview ¶
Package burndown provides file-level line interval tracking for burndown analysis.
Index ¶
- Constants
- func NewTreapTimeline(time, length int) *treapTimeline
- type DeltaReport
- type File
- func (file *File) CloneDeep() *File
- func (file *File) CloneShallow() *File
- func (file *File) Delete()
- func (file *File) Dump() string
- func (file *File) ForEach(callback func(line, value int))
- func (file *File) InvalidateIndex()
- func (file *File) Len() int
- func (file *File) Merge(day int, others ...*File)
- func (file *File) MergeAdjacentSameValue()
- func (file *File) Nodes() int
- func (file *File) QueryRange(startLine, endLine int) []OwnershipSegment
- func (file *File) ReconstructFromSegments(segs []Segment)
- func (file *File) ReplaceUpdaters(updaters []Updater)
- func (file *File) Segments() []Segment
- func (file *File) ShrinkPool(keep int)
- func (file *File) Update(time, pos, insLength, delLength int)
- func (file *File) Validate()
- type OwnershipSegment
- type Segment
- type TimeKey
- type Timeline
- type Updater
Constants ¶
const TreeEnd = math.MaxUint32
TreeEnd denotes the value of the last leaf in the tree.
const TreeMaxBinPower = 14
TreeMaxBinPower is the binary power value which corresponds to the maximum tick which can be stored in the tree.
const TreeMergeMark = (1 << TreeMaxBinPower) - 1
TreeMergeMark is the special day which disables the status updates and is used in File.Merge().
Variables ¶
This section is empty.
Functions ¶
func NewTreapTimeline ¶
func NewTreapTimeline(time, length int) *treapTimeline
NewTreapTimeline creates a Timeline backed by an implicit treap with initial [0, length) at time t.
Types ¶
type DeltaReport ¶
DeltaReport is a single (currentTime, previousTime, delta) for updater callbacks.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File encapsulates a Timeline (line-interval storage) and cumulative length counters via updaters. Users should call NewFile(); Len() returns line count; Update() mutates via the timeline and updaters. Dump() writes the tree to a string and Validate() checks integrity.
func NewFile ¶
NewFile initializes a new instance of File struct using the default treap timeline.
The time parameter is the starting value of the first node. The length parameter is the starting length of the tree (the key of the second and the last node). The updaters parameter lists the attached interval length mappings.
func NewFileFromSegments ¶
NewFileFromSegments creates a File from serialized segments without triggering updaters.
func (*File) CloneShallow ¶
CloneShallow copies the file (shallow copy of the timeline).
func (*File) Dump ¶
Dump formats the underlying line interval tree into a string. Useful for error messages, panic()-s and debugging.
func (*File) ForEach ¶
ForEach visits each segment start in the timeline in order (line, value); value is -1 for TreeEnd.
func (*File) InvalidateIndex ¶
func (file *File) InvalidateIndex()
InvalidateIndex marks the interval tree index as needing a rebuild. Called automatically by Update.
func (*File) MergeAdjacentSameValue ¶
func (file *File) MergeAdjacentSameValue()
MergeAdjacentSameValue coalesces consecutive segments with the same time (reduces node count).
func (*File) QueryRange ¶
func (file *File) QueryRange(startLine, endLine int) []OwnershipSegment
QueryRange returns all ownership segments that overlap the line range [startLine, endLine). The interval tree index is rebuilt lazily when the timeline has been modified. TreeEnd sentinel segments are excluded from results.
func (*File) ReconstructFromSegments ¶
ReconstructFromSegments rebuilds the file's timeline from a compact segment slice.
func (*File) ReplaceUpdaters ¶
ReplaceUpdaters replaces the file's updaters with a new set.
func (*File) ShrinkPool ¶
ShrinkPool trims the timeline's internal node pool to retain at most keep free nodes. Call between chunks to release excess pool memory to the GC.
type OwnershipSegment ¶
OwnershipSegment represents a line range with a single owner (time value).
type Segment ¶
Segment represents a contiguous run of lines with the same time value. Used for compact serialization of treap state (segments vs per-line expansion).
type TimeKey ¶
type TimeKey = uint32
TimeKey is the time (tick) associated with a line interval. Same semantics as tree Value.
type Timeline ¶
type Timeline interface {
// Replace applies delete [pos, pos+delLines) then insert insLines at pos with time t.
// Returns delta reports for the caller to apply to updaters (e.g. from deleted intervals).
Replace(pos, delLines, insLines int, t TimeKey) []DeltaReport
// Iterate calls fn(offset, length, timeKey) for each segment in order; return false to stop.
Iterate(fn func(offset int, length int, t TimeKey) bool)
// Len returns total line count (file length).
Len() int
// Nodes returns the number of segments/nodes (for diagnostics).
Nodes() int
// Validate panics if invariants are violated.
Validate()
// CloneShallow returns a shallow copy of the timeline.
CloneShallow() *treapTimeline
// CloneDeep returns a deep copy of the timeline.
CloneDeep() *treapTimeline
// Erase clears all nodes (for Delete).
Erase()
// Flatten returns line→time as a slice (for Merge).
Flatten() []int
// Reconstruct rebuilds from line→time slice (for Merge).
Reconstruct(lines []int)
// MergeAdjacentSameValue coalesces consecutive segments with the same time (reduces node count).
// No-op for implementations that do not benefit (e.g. implicit treap).
MergeAdjacentSameValue()
// Segments returns the treap's segments as a compact slice (excludes TreeEnd sentinel).
Segments() []Segment
// ReconstructFromSegments rebuilds from a compact segment slice (inverse of Segments).
ReconstructFromSegments(segs []Segment)
}
Timeline stores line intervals by (implicit or explicit) position and supports Replace without O(N) key shifting. Default implementation: implicit treap.