Documentation ¶
Index ¶
- type Stream
- func (s *Stream[T]) Get(from int, qty int) ([]T, error)
- func (s *Stream[T]) GetItems() []T
- func (s *Stream[T]) GetOne(index int) (T, error)
- func (s *Stream[T]) IsDone(from int, qty int) bool
- func (s *Stream[T]) IsEmpty() bool
- func (s *Stream[T]) Iterator() ll.Iterater[T]
- func (s *Stream[T]) Size() int
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 quantity or from is negative.
Behaviors:
- Use qty -1 to get all items from 'from' to the end of the stream.
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]) GetOne ¶ added in v0.3.1
GetOne returns the item at the given index.
Parameters:
- index: The index of the item to get.
Returns:
- T: The item at the given index.
- error: An error if the index is negative or out of bounds.
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.
func (*Stream[T]) IsEmpty ¶
IsEmpty returns true if the stream is empty.
Returns:
- bool: True if the stream is empty.
Click to show internal directories.
Click to hide internal directories.