Skip to content

Operation reverse

Iván Corrales Solera edited this page Dec 2, 2018 · 2 revisions

stream.Reverse

It reverses the sequence of the stream elements.

Signature

func (s stream.Stream) Reverse() (out *Output)

Arguments

N/A

Output

Name Type Description
out stream.Stream It returns the stream

Errors

Type Description
err.items-nil The stream doesn't have elements

Example

package main

import (
  "fmt"
  "github.com/wesovilabs/koazee"
)

var stream = koazee.StreamOf([]int{1, 2, 3, 4, 5})

func main() {
  out := stream.Reverse().Do()
  fmt.Println(out.Out().Val().([]int))
}

Download

Benchmark

Reversing sequence of elements in a stream of strings

Test Identifier Stream Len Speed
BenchmarkReverseString10-4 10 477 ns/op
BenchmarkReverseString100-4 100 1218 ns/op
BenchmarkReverseString1000-4 1000 7505 ns/op
BenchmarkReverseString5000-4 5000 37553 ns/op