set

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

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

Go to latest
Published: Apr 7, 2014 License: MIT Imports: 2 Imported by: 13

README

goset Build Status

Implementation of the Set data structure, written in Go. MIT Licensed.

Full documentation for goset may be found on GoDoc.

More information on the Set data structure may be found on Wikipedia.

Documentation

Overview

Package set provides a Go implementation of the Set data structure, with a number of useful methods which can be performed on the Set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pair

type Pair struct {
	X interface{}
	Y interface{}
}

Pair represents a pair of elements created from a cartesian product

func (*Pair) String

func (p *Pair) String() string

String returns a string representation of this pair

type Set

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

Set represents an unordered collection of unique values

func New

func New(values ...interface{}) *Set

New creates a new Set, and initializes its internal map, optionally adding initial elements to the set

func (*Set) Add

func (s *Set) Add(value interface{}) bool

Add inserts a new element into the set, returning true if the element was newly added, or false if it already existed

func (*Set) CartesianProduct

func (s *Set) CartesianProduct(t *Set) *Set

CartesianProduct returns a set containing ordered pairs of every permutation between two sets

func (*Set) Clone

func (s *Set) Clone() *Set

Clone copies the current set into a new, identical set

func (*Set) Difference

func (s *Set) Difference(t *Set) *Set

Difference returns a set containing all elements present in this set, but without any elements present in the parameter set

func (*Set) Enumerate

func (s *Set) Enumerate() []interface{}

Enumerate returns an unordered slice of all elements in the set

func (*Set) Equal

func (s *Set) Equal(t *Set) bool

Equal returns whether or not two sets have the same length and no differences, meaning they are equal

func (*Set) Filter

func (s *Set) Filter(fn func(interface{}) bool) *Set

Filter applies a function over all elements of the set, and returns all elements which return true when the function is applied

func (*Set) Has

func (s *Set) Has(value interface{}) bool

Has checks for membership of an element in the set

func (*Set) Intersection

func (s *Set) Intersection(t *Set) *Set

Intersection returns a set containing all elements present in both the current set and the parameter set

func (*Set) Map

func (s *Set) Map(fn func(interface{}) interface{}) *Set

Map applies a function over all elements of the set, and returns the resulting set

func (*Set) PowerSet

func (s *Set) PowerSet() *Set

PowerSet generates a set of all possible subsets, given the current set

func (*Set) Reduce

func (s *Set) Reduce(value interface{}, fn func(interface{}, interface{}) interface{}) interface{}

Reduce applies a function over all elements of the set, accumulating the results into a final result value

func (*Set) Remove

func (s *Set) Remove(value interface{}) bool

Remove destroys an element in the set, returning true if the element was destroyed, or false if it did not exist

func (*Set) Size

func (s *Set) Size() int

Size returns the size or cardinality of this set

func (*Set) String

func (s *Set) String() string

String returns a string representation of this set

func (*Set) Subset

func (s *Set) Subset(t *Set) bool

Subset determines if a parameter set is a subset of elements within this set, returning true if it is a subset, or false if it is not

func (*Set) SymmetricDifference

func (s *Set) SymmetricDifference(t *Set) *Set

SymmetricDifference returns a set containing all elements which are not shared between this set and the parameter set

func (*Set) Union

func (s *Set) Union(t *Set) *Set

Union returns a set containing all elements present in this set, as well as all elements present in the parameter set

Jump to

Keyboard shortcuts

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