gotemplate: github.com/ncw/gotemplate/set Index | Files

package set

import "github.com/ncw/gotemplate/set"

Package set is a template Set type

Tries to be similar to Python's set type

Index

Package Files

set.go

type A Uses

type A int

An A is the element of the set

template type Set(A)

type Set Uses

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

Set provides a general purpose set modeled on Python's set type.

func NewSet Uses

func NewSet() *Set

NewSet returns a new empty set

func NewSizedSet Uses

func NewSizedSet(capacity int) *Set

NewSizedSet returns a new empty set with the given capacity

func (*Set) Add Uses

func (s *Set) Add(elem A) *Set

Add adds elem to the set, returning the set

If the element already exists then it has no effect

func (*Set) AddList Uses

func (s *Set) AddList(elems []A) *Set

AddList adds a list of elems to the set

If the elements already exists then it has no effect

func (*Set) AsList Uses

func (s *Set) AsList() []A

AsList returns all the elements as a slice

func (*Set) Clear Uses

func (s *Set) Clear() *Set

Clear removes all the elements

func (*Set) Contains Uses

func (s *Set) Contains(elem A) bool

Contains returns whether elem is in the set or not

func (*Set) Copy Uses

func (s *Set) Copy() *Set

Copy returns a shallow copy of the Set

func (*Set) Difference Uses

func (s *Set) Difference(other *Set) *Set

Difference returns a new set with all the elements that are in this set but not in the other

func (*Set) DifferenceUpdate Uses

func (s *Set) DifferenceUpdate(other *Set) *Set

DifferenceUpdate removes all the elements that are in the other set from this set. It returns the set.

func (*Set) Discard Uses

func (s *Set) Discard(elem A) *Set

Discard removes elem from the set

If it wasn't in the set it does nothing

It returns the set

func (*Set) Intersection Uses

func (s *Set) Intersection(other *Set) *Set

Intersection returns a new set with all the elements that are only in this set and the other set. It returns the new set.

func (*Set) IntersectionUpdate Uses

func (s *Set) IntersectionUpdate(other *Set) *Set

IntersectionUpdate changes this set so that it only contains elements that are in both this set and the other set. It returns the set.

func (*Set) IsDisjoint Uses

func (s *Set) IsDisjoint(other *Set) bool

IsDisjoint returns a bool indicating whether this set and other set have no elements in common.

func (*Set) IsSubset Uses

func (s *Set) IsSubset(strict bool, other *Set) bool

IsSubset returns a bool indicating whether this set is a subset of other set.

func (*Set) IsSuperset Uses

func (s *Set) IsSuperset(strict bool, other *Set) bool

IsSuperset returns a bool indicating whether this set is a superset of other set.

func (*Set) Len Uses

func (s *Set) Len() int

Len returns the number of elements in the set

func (*Set) Pop Uses

func (s *Set) Pop(elem A) (A, bool)

Pop removes elem from the set and returns it

It also returns whether the elem was found or not

func (*Set) Remove Uses

func (s *Set) Remove(elem A) bool

Remove removes elem from the set

It returns whether the elem was in the set or not

func (*Set) SymmetricDifference Uses

func (s *Set) SymmetricDifference(other *Set) *Set

SymmetricDifference returns a new set of all elements that are a member of exactly one of this set and other set(elements which are in one of the sets, but not in both).

func (*Set) SymmetricDifferenceUpdate Uses

func (s *Set) SymmetricDifferenceUpdate(other *Set) *Set

SymmetricDifferenceUpdate modifies this set to be a set of all elements that are a member of exactly one of this set and other set(elements which are in one of the sets, but not in both) and returns this set.

func (*Set) Union Uses

func (s *Set) Union(other *Set) *Set

Union returns a new set with all the elements that are in either set. It returns the new set.

func (*Set) Update Uses

func (s *Set) Update(other *Set) *Set

Update adds all the elements from the other set to this set. It returns the set.

type SetNothing Uses

type SetNothing struct{}

SetNothing is used as a zero sized member in the map

Updated 2017-05-11. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).