Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
Stream is a stream of items.
Side effects:
- Modifications to the elements inserted and removed from the stream can affect the stream's values. Especially if the elements are pointers.
func NewStream ¶
NewStream creates a new stream with the given items.
Parameters:
- items: The items to add to the stream.
Returns:
- Stream: The new stream.
func (*Stream[T]) Get ¶ added in v0.2.36
Get returns qty of items from the stream starting from the given index.
Parameters:
- from: The index of the first item to get.
- qty: The number of items to get.
Returns:
- []T: The items from the stream.
- error: An error if there are no more items in the stream or if the qty is negative.
func (*Stream[T]) GetItems ¶
func (s *Stream[T]) GetItems() []T
GetItems returns the items in the stream.
Returns:
- []T: The items in the stream.
func (*Stream[T]) IsDone ¶
IsDone returns true if from + qty is greater than the number of items in the stream.
Returns:
- bool: True if the stream has been fully consumed. False otherwise.
type Streamer ¶
type Streamer[T any] interface { // Size returns the number of items in the stream. // // Returns: // - int: The number of items in the stream. Size() int // IsEmpty returns true if the stream is empty. // // Returns: // - bool: True if the stream is empty. IsEmpty() bool // Get returns qty of items from the stream starting from the given index. // // Parameters: // - from: The index of the first item to get. // - qty: The number of items to get. // // Returns: // - []T: The items from the stream. // - error: An error of type *ers.ErrInvalidParameter if from or qty is negative. // // Behaviors: // - If there are not enough items in the stream, no error is returned // but the number of items returned will be less than qty. Get(from int, qty int) ([]T, error) // IsDone returns true if from + qty is greater than the number of items in the stream. // // Parameters: // - from: The index of the first item to check. // - qty: The number of items to check. // // Returns: // - bool: True if the stream has been fully consumed. IsDone(from int, qty int) bool // GetItems returns the items in the stream. // // Returns: // - []T: The items in the stream. GetItems() []T }
Streamer is an interface for streams of items.
Click to show internal directories.
Click to hide internal directories.