Documentation ¶
Index ¶
- func ToSlice[T constraints.Ordered](stream SortedNumbersStream[T]) []T
- type ChannelStream
- type SliceStream
- type SortedNumbersStream
- func Diff[T constraints.Ordered](stream1, stream2 SortedNumbersStream[T], asc bool) SortedNumbersStream[T]
- func Intersect[T constraints.Ordered](stream1, stream2 SortedNumbersStream[T], asc bool) SortedNumbersStream[T]
- func Union[T constraints.Ordered](stream1, stream2 SortedNumbersStream[T], asc bool) SortedNumbersStream[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToSlice ¶
func ToSlice[T constraints.Ordered](stream SortedNumbersStream[T]) []T
Types ¶
type ChannelStream ¶
type ChannelStream[T constraints.Ordered] struct { // contains filtered or unexported fields }
ChannelStream is used as a result of operation on other streams
func NewChannelStream ¶
func NewChannelStream[T constraints.Ordered]() *ChannelStream[T]
func (*ChannelStream[T]) Close ¶
func (s *ChannelStream[T]) Close()
func (*ChannelStream[T]) Next ¶
func (s *ChannelStream[T]) Next() (item T, ok bool)
func (*ChannelStream[T]) Push ¶
func (s *ChannelStream[T]) Push(item T)
type SliceStream ¶
type SliceStream[T constraints.Ordered] struct { // contains filtered or unexported fields }
SliceStream implements SortedNumbersStream for static slices (convenient in tests)
func NewSliceStream ¶
func NewSliceStream[T constraints.Ordered](slice []T) *SliceStream[T]
func (*SliceStream[T]) Next ¶
func (s *SliceStream[T]) Next() (item T, ok bool)
func (*SliceStream[T]) Reset ¶
func (s *SliceStream[T]) Reset()
type SortedNumbersStream ¶
type SortedNumbersStream[T constraints.Ordered] interface { // Next return the next available item from the sorted stream // ok shows if the stream is drained and no further read will give anything (like a closed channel) Next() (item T, ok bool) }
SortedNumbersStream allows to iterate over sorted data Algorithms imply the data behind this interface is sorted
func Diff ¶
func Diff[T constraints.Ordered](stream1, stream2 SortedNumbersStream[T], asc bool) SortedNumbersStream[T]
Diff returns the stream consisting of elements that are in stream1 but not in stream2
func Intersect ¶
func Intersect[T constraints.Ordered](stream1, stream2 SortedNumbersStream[T], asc bool) SortedNumbersStream[T]
Intersect returns the stream consisting of elements that are in both stream1 and stream2
func Union ¶
func Union[T constraints.Ordered](stream1, stream2 SortedNumbersStream[T], asc bool) SortedNumbersStream[T]
Union returns the stream consisting of elements that are either in stream1 or stream2
Click to show internal directories.
Click to hide internal directories.