set

package module
v0.0.0-...-5798a3b Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2015 License: Apache-2.0 Imports: 3 Imported by: 3

README

goset

Simple set library for golang which puts an emphasis on usability over performance.

Installation

You can download the code via the usual go utilities:

go get github.com/datacratic/goset

To build the code and run the test suite along with several static analysis tools, use the provided Makefile:

make test

Note that the usual go utilities will work just fine but we require that all commits pass the full suite of tests and static analysis tools.

Examples

Usage examples are available in the following test suite.

Performance

Set is currently fairly slow and lots of work has to be done to tune it performance-wise. The main bottleneck that was observed on live code was the underlying go map data-structure which forces lots of memory allocation.

License

The source code is available under the Apache License. See the LICENSE file for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int

type Int map[int64]struct{}

Int represents a set of int64s. Must first be initialized using the NewInt function before being used.

func NewInt

func NewInt(values ...int64) Int

NewInt creates a new int64 set from the given list of int64s.

func (Int) Array

func (set Int) Array() (list []int64)

Array returns a sorted array of all the values in the current set.

func (Int) Copy

func (set Int) Copy() Int

Copy returns a copy of the set.

func (Int) Del

func (set Int) Del(values ...int64)

Del removes the given int64 from the set and is a noop if the int64 is not already in the set.

func (Int) Difference

func (set Int) Difference(other Int) Int

Difference returns a set consisting of all the values in this set that are not present in the other set.

func (Int) Intersect

func (set Int) Intersect(other Int) Int

Intersect returns a set consisting of the values present in both sets.

func (Int) Merge

func (set Int) Merge(other Int)

Merge adds all the values of other into the set.

func (Int) Put

func (set Int) Put(values ...int64)

Put adds the given int64 to the set and is a noop if the int64 is already in the set.

func (Int) String

func (set Int) String() string

String returns a int64 representation of the set suitable for debugging.

func (Int) Test

func (set Int) Test(values ...int64) bool

Test returns true if the given int64 is in the set.

func (Int) Union

func (set Int) Union(other Int) Int

Union returns a set consisting of all values present in both other and the current set.

type String

type String map[string]struct{}

String represents a set of strings. Must first be initialized using the NewString function before being used.

func NewString

func NewString(values ...string) String

NewString creates a new string set from the given list of strings.

func (String) Array

func (set String) Array() (list []string)

Array returns a sorted array of all the values in the current set.

func (String) Copy

func (set String) Copy() String

Copy returns a copy of the set.

func (String) Del

func (set String) Del(values ...string)

Del removes the given string from the set and is a noop if the string is not already in the set.

func (String) Difference

func (set String) Difference(other String) String

Difference returns a set consisting of all the values in this set that are not present in the other set.

func (String) Intersect

func (set String) Intersect(other String) String

Intersect returns a set consisting of the values present in both sets.

func (String) Merge

func (set String) Merge(other String)

Merge adds all the values of other into the set.

func (String) Put

func (set String) Put(values ...string)

Put adds the given string to the set and is a noop if the string is already in the set.

func (String) String

func (set String) String() string

String returns a string representation of the set suitable for debugging.

func (String) Test

func (set String) Test(values ...string) bool

Test returns true if the given string is in the set.

func (String) Union

func (set String) Union(other String) String

Union returns a set consisting of all values present in both other and the current set.

type Uint

type Uint map[uint64]struct{}

Uint represents a set of uint64s. Must first be initialized using the NewUint function before being used.

func NewUint

func NewUint(values ...uint64) Uint

NewUint creates a new uint64 set from the given list of uint64s.

func (Uint) Array

func (set Uint) Array() (list []uint64)

Array returns a sorted array of all the values in the current set.

func (Uint) Copy

func (set Uint) Copy() Uint

Copy returns a copy of the set.

func (Uint) Del

func (set Uint) Del(values ...uint64)

Del removes the given uint64 from the set and is a noop if the uint64 is not already in the set.

func (Uint) Difference

func (set Uint) Difference(other Uint) Uint

Difference returns a set consisting of all the values in this set that are not present in the other set.

func (Uint) Intersect

func (set Uint) Intersect(other Uint) Uint

Intersect returns a set consisting of the values present in both sets.

func (Uint) Merge

func (set Uint) Merge(other Uint)

Merge adds all the values of other into the set.

func (Uint) Put

func (set Uint) Put(values ...uint64)

Put adds the given uint64 to the set and is a noop if the uint64 is already in the set.

func (Uint) String

func (set Uint) String() string

String returns a uint64 representation of the set suitable for debugging.

func (Uint) Test

func (set Uint) Test(values ...uint64) bool

Test returns true if the given uint64 is in the set.

func (Uint) Union

func (set Uint) Union(other Uint) Uint

Union returns a set consisting of all values present in both other and the current set.

Jump to

Keyboard shortcuts

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