Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Done = errors.New("no more values left")
)
Functions ¶
func MergeFiles ¶
MergeFiles merges k sorted sequences into a signle one. Takes O(n log k) time with O(k) space complexity. Where k is the number of sequences and n is the total number of elements combined.
func PrintKSorted ¶
func PrintKSorted(iter IntSliceIter, k int)
PrintKSorted prints almost sorted array in sorted order where each elements is at most k position away from it's correct position. Takes O(n log k) time with O(k) space complexity.
func SortKIncDec ¶
SortKIncDec sorts array that contains multiple sorted inc/dec sequences in one sorted sequence. Takes O(n log k) time with O(k) space complexity. where k is the number of sorted arrays and n is the total number of elements.
Types ¶
type IntSliceIter ¶
type IntSliceIter struct {
// contains filtered or unexported fields
}
func NewIntSliceIter ¶
func NewIntSliceIter(s []int) IntSliceIter
func (*IntSliceIter) Less ¶
func (iter *IntSliceIter) Less(other IntSliceIter) bool
func (*IntSliceIter) Next ¶
func (iter *IntSliceIter) Next() (int, error)
type IntSliceIterHeap ¶
type IntSliceIterHeap []IntSliceIter
An IntSliceIterHeap is a min-heap of IntSliceIter.
func (IntSliceIterHeap) Len ¶
func (h IntSliceIterHeap) Len() int
func (IntSliceIterHeap) Less ¶
func (h IntSliceIterHeap) Less(i, j int) bool
func (*IntSliceIterHeap) Pop ¶
func (h *IntSliceIterHeap) Pop() interface{}
func (*IntSliceIterHeap) Push ¶
func (h *IntSliceIterHeap) Push(x interface{})
func (IntSliceIterHeap) Swap ¶
func (h IntSliceIterHeap) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.