gomap

package module
v0.0.0-...-ae242fd Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 3 Imported by: 0

README

GoMap

Go Report Card GoDoc License

In Golang, we have the built-in map which is using hashmap to implement O(N).

However, the performance of hashing algorithm is not go at all.

By creating this package, I am aiming to implement many types of Map which support more purposes but easily to change between the algorithm in the blackbox.

Goals

  • Generics - Type Safe.
  • Support thread-safe.
  • Easy to switch map types.
  • Support Bloom filter if key's type is integer.
  • Stat functions: hit-rate, size, time of operations.

API Documentation

For detailed documentation, please refer to the GoDoc page.

Contributing

Contributions are welcome! Please feel free to open issues or pull requests for bug fixes, improvements, or new features.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPureMap

func NewPureMap[K comparable, V any]() *pureMap[K, V]

NewPureMap creates a new pureMap instance

Types

type Map

type Map[K comparable, V any] interface {
	Store(key K, val V)
	Load(key K) (V, bool)
	LoadAndDelete(key K) (V, bool)
	Delete(key K)
	Contain(key K) bool
	Clear()
}

func NewIntSortedSliceMap

func NewIntSortedSliceMap[K constraints.Integer, V any](opts ...Option) Map[K, V]

NewIntSortedSliceMap create sorted slice map, using binary search to find the item using bloom filter to predict if the item doesn't exist non-thread-safe

func NewSortedSliceMap

func NewSortedSliceMap[K constraints.Ordered, V any](opts ...Option) Map[K, V]

NewSortedSliceMap create sorted slice map, using binary search to find the item non-thread-safe

func NewSyncMap

func NewSyncMap[K comparable, V any](opts ...Option) Map[K, V]

func NewThreadSafeIntSortedSliceMap

func NewThreadSafeIntSortedSliceMap[K constraints.Integer, V any](opts ...Option) Map[K, V]

NewThreadSafeIntSortedSliceMap creates a new threadSafeIntSortedSliceMap instance

func NewThreadSafePureMap

func NewThreadSafePureMap[K comparable, V any]() Map[K, V]

NewThreadSafePureMap creates a new threadSafePureMap instance

func NewThreadSafeSortedSliceMap

func NewThreadSafeSortedSliceMap[K constraints.Ordered, V any](opts ...Option) Map[K, V]

NewThreadSafeSortedSliceMap creates a new threadSafeSortedSliceMap instance If your key is Integer, please consider to use IntSortedSliceMap to have bloom filter feature

type Option

type Option func(o *option)

func WithCap

func WithCap(cap int) Option

Jump to

Keyboard shortcuts

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