Skip to content

Distinct Elements in Streams, Golang implementation

License

Notifications You must be signed in to change notification settings

betamos/distinct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distinct

This micro-library estimates the number of distinct elements in a stream:

import (
    "fmt"
    "github.com/betamos/distinct"
)

// Uses a map of size 200
c := distinct.NewCounter[int](200, nil)
for i := 0; i < 100000; i++ {
	c.Add(i % 300)
}
fmt.Println(c.Estimate()) // Should be somewhere around 300

It's based on Distinct Elements in Streams: An Algorithm for the (Text) Book.

About

Distinct Elements in Streams, Golang implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages