minmaxcnt

package module
v0.0.0-...-136c25e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2020 License: GPL-3.0 Imports: 1 Imported by: 1

README

Build Status Coverage Status Go Report Card GoDoc GPLv3 licensed

minmaxcnt

Data structure with Increment, Decrement, Count, Min and Max functions all running in O(1) constant time.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {

	// Increment increases the count associated with the key by 1.
	// If the key doesn't exist, it is created with count of 1.
	Increment(key interface{})

	// Decrement decreases the count associated with the key by 1.
	// If the key doesn't exist, the result is no operation.
	// If as a result, the count drops to zero, it is removed.
	// Counts can never become negative hence the 'uint'.
	Decrement(key interface{})

	// Count returns the current count of the given key.
	// If the key does not exist, zero is returned.
	Count(key interface{}) uint

	// Max deterministically returns the key with the highest count.
	// Of the keys sharing the same maximum count, the oldest of them is returned.
	Max() (interface{}, uint)

	// Min deterministically returns the key with the lowest non-zero count.
	// Of the keys sharing the same minimum count, the newest of them is returned.
	Min() (interface{}, uint)
}

Interface represents all permitted operations that run in O(1) time: constant time operations.

func New

func New() Interface

New returns a new instance of a BigOhOne data structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL