runeset

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: BSD-3-Clause Imports: 2 Imported by: 5

README

runeset

GoDoc

A simple set type for Unicode characters in Go (a.k.a. runes).

Documentation

Overview

Example
s1 := MakeFromString("1234567")
s2 := MakeFromString("86420")
fmt.Println(s1.Intersection(s2))
Output:

Set{2 4 6}
Example (InvertedIndex)
index := make(map[string]Set)
index["CHESS"] = Make('♚', '♛', '♜', '♝', '♞', '♟', '♔', '♕', '♖', '♗', '♘', '♙')
index["BLACK"] = Make('⚑', '■', '🖤', '★', '☎', '☻', '♚', '♛', '♜', '♝', '♞', '♟', '♠', '♣', '✂', '㉈')
index["REGISTERED"] = Make('®')
result := index["CHESS"].Intersection(index["BLACK"])
fmt.Println(result)
Output:

Set{♚ ♛ ♜ ♝ ♞ ♟}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[rune]struct{}

Set represents a set of runes

func Make

func Make(chars ...rune) Set

Make creates and returns a new Set

func MakeFromString

func MakeFromString(text string) Set

MakeFromString creates and returns a new Set

func (Set) Add

func (s Set) Add(r rune)

Add a rune to the set.

func (Set) Contains

func (s Set) Contains(r rune) bool

Contains reports whether set contains given rune

func (Set) Copy

func (s Set) Copy() Set

Copy returns a new Set: a copy of s.

func (Set) Equal

func (s Set) Equal(other Set) bool

Equal reports whether set is equal to other

func (Set) Intersection

func (s Set) Intersection(other Set) Set

Intersection returns a new set: the intersection of s AND other

func (Set) IntersectionUpdate

func (s Set) IntersectionUpdate(other Set)

IntersectionUpdate changes receiver in-place, keeping only elements that are in it AND in other.

func (Set) Sorted

func (s Set) Sorted() []rune

Sorted returns sorted slice with runes from s

func (Set) String

func (s Set) String() string

Jump to

Keyboard shortcuts

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