Set3

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

README

Set3

Set3 is a fast and pure set implmentation in and for Golang.

The code is derived from SwissMap and it is implementing the "Fast, Efficient, Cache-friendly Hash Table" found in Abseil. For details on the algorithm see the CppCon 2017 talk by Matt Kulukundis. The dependency on x86 assembler for SSE instructions has been removed for portability and speed (yes, the code is faster without SSE).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set3

type Set3[K comparable] struct {
	// contains filtered or unexported fields
}

Set3 is an open-addressing Set3 based on Abseil's flat_hash_map.

func NewSet3

func NewSet3[K comparable](sz uint32) (s *Set3[K])

NewSet3 constructs a Set3.

func (*Set3[K]) Add

func (Set3 *Set3[K]) Add(element K)

Add attempts to insert |key| and |value|

func (*Set3[K]) Capacity

func (Set3 *Set3[K]) Capacity() int

Capacity returns the number of additional elements the can be added to the Map before resizing.

func (*Set3[K]) Clear

func (Set3 *Set3[K]) Clear()

Clear removes all elements from the Map.

func (*Set3[K]) Contains

func (Set3 *Set3[K]) Contains(element K) bool

Contains returns true if |element| is present in the |Set3|.

func (*Set3[K]) Count

func (Set3 *Set3[K]) Count() int

Count returns the number of elements in the Map.

func (*Set3[K]) Iter

func (Set3 *Set3[K]) Iter(callBack func(element K) (stop bool))

Iter iterates the elements of the Map, passing them to the callback. It guarantees that any key in the Map will be visited only once, and for un-mutated Maps, every key will be visited once. If the Map is Mutated during iteration, mutations will be reflected on return from Iter, but the Set3 of keys visited by Iter is non-deterministic.

func (*Set3[K]) Remove

func (Set3 *Set3[K]) Remove(element K) bool

Remove attempts to remove |element|, returns true if the |element| was in the |Set3|

Jump to

Keyboard shortcuts

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