chansort

package module
v0.0.0-...-4abe4b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 3 Imported by: 0

README

DEPRECATION NOTICE

Please note this package can now be found at https://github.com/jamesrom/order

chansort

A sliding-window buffer for ordering channel messages

See also: https://github.com/jamesrom/priorityqueue

  • Documentation
  • Benchmarks
  • Concurrency tests

Documentation

Overview

Deprecated: chansort has now moved to github.com/jamesrom/order/chansort

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortOrderable

func SortOrderable[T constraints.Ordered](in <-chan T, window time.Duration) <-chan T

SortOrderable sorts channel messages in ascending order. Messages received inside the sliding-window buffer defined by _window_ are sent to the output channel in ascending order. That is to say: a message received at time _Z_ from the output channel is guaranteed to be the smallest message since _Z − window_.

func SortWithComparator

func SortWithComparator[T any](in <-chan T, window time.Duration, fn Less[T]) <-chan T

SortWithComparator sorts channel messages in the order defined by the given comparator function. Messages received inside the sliding-window buffer defined by _window_ are sent to the output channel in order. That is to say: a message received at time _Z_ from the output channel is guaranteed to be the smallest message since _Z − window_.

Types

type Less

type Less[T any] func(T, T) bool

Less must describe a transitive ordering:

  • if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well.
  • if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL