Skip to content

Operation deleteAt

Iván Corrales Solera edited this page Dec 9, 2018 · 1 revision

stream.Drop

It deletes the element in the given position in the stream

Signature

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

Errors

Type Description
err.items-nil The stream is nil
index int

Example

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))
}

Download

Benchmark

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