sparse

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: BSD-3-Clause Imports: 0 Imported by: 14

Documentation

Overview

Package sparse implements sparse sets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set struct {
	// contains filtered or unexported fields
}

A Set is a sparse set of uint32 values. http://research.swtch.com/2008/03/using-uninitialized-memory-for-fun-and.html

func NewSet

func NewSet(max uint32) *Set

NewSet returns a new Set with a given maximum size. The set can contain numbers in [0, max-1].

func (*Set) Add

func (s *Set) Add(x uint32)

Add adds x to the set if it is not already there.

func (*Set) Dense

func (s *Set) Dense() []uint32

Dense returns the values in the set. The values are listed in the order in which they were inserted.

func (*Set) Has

func (s *Set) Has(x uint32) bool

Has reports whether x is in the set.

func (*Set) Init

func (s *Set) Init(max uint32)

Init initializes a Set to have a given maximum size. The set can contain numbers in [0, max-1].

func (*Set) Len

func (s *Set) Len() int

Len returns the number of values in the set.

func (*Set) Reset

func (s *Set) Reset()

Reset clears (empties) the set.

Jump to

Keyboard shortcuts

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