Repository navigation
Operation deleteAt
Iván Corrales Solera edited this page Dec 9, 2018
·
1 revision
It deletes the element in the given position in the stream
func (s stream.Stream) DeleteAt(index int) (out stream)Arguments
| Name | Type | Description |
|---|---|---|
| index | int | Index of element to be deleted |
Output
| Name | Type | Description |
|---|---|---|
| out | stream.Stream | It returns the stream |
| Type | Description |
|---|---|
| err.items-nil | The stream is nil |
| index | int |
package main
import (
"fmt"
"github.com/wesovilabs/koazee"
)
var stream = koazee.StreamOf([]string{"Dog","Cat","Monkey","Rabbit","Turtle"})
func main() {
out:=stream.DeleteAt(1).Do()
fmt.Println(out.Out().Val().([]string))
}Delete an element in the given position
| Test Identifier | Stream Len | Speed |
|---|---|---|
| BenchmarkAddString10-4 | 10 | 484 ns/op |
| BenchmarkAddString100-4 | 100 | 1035 ns/op |
| BenchmarkAddString1000-4 | 1000 | 5806 ns/op |
| BenchmarkAddString5000-4 | 5000 | 31917 ns/op |
Remove an element (that does not exist) from a stream of strings
| Test Identifier | Stream Len | Speed |
|---|---|---|
| BenchmarkDropString10UnExistingElement-4 | 10 | 584 ns/op |
| BenchmarkDropString100UnExistingElement-4 | 100 | 711 ns/op |
| BenchmarkDropString1000UnExistingElement-4 | 1000 | 1393 ns/op |
| BenchmarkDropString5000UnExistingElement-4 | 5000 | 3763 ns/op |
@2018 Koazee by Iván Corrales Solera developer@wesovilabs.com