10000 GitHub - EC-TSJ/set
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

EC-TSJ/set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Set

Home Build Status Coverage Status Go Report Card

EN README

Set es una librería para manipular la DataStructure set.

GoDoc

Funciones Principales


Tiene los objetos siguientes:

  • Type struct Element, para realizar las definiciones.

  • type []Element Set con métodos:

    • ToSet() ISet
    • String() string
  • Type ìnterface ISet, con métodos:

    • Add(i Item) bool
    • Cardinality() int
    • Clear()
    • Clone() Set
    • Contains(i ...Item) bool
    • Difference(other Set) Set
    • Equal(other Set) bool
    • Intersect(other Set) Set
    • IsProperSubset(other Set) bool
    • IsProperSuperset(other Set) bool
    • IsSubset(other Set) bool
    • IsSuperset(other Set) bool
    • Each(func(Item) bool)
    • Iter() <-chan interface{}
    • Iterator() *Iterator
    • Remove(i Item)
    • String() string
    • SymmetricDifference(other Set) Set
    • Union(other Set) Set
    • Pop() Item
    • PowerSet() Set
    • CartesianProduct(other Set) Set
    • ToSlice() []Item
    • MarshalJSON() ([]byte, error)
    • UnmarshalJSON(b []byte) error
  • Type struct Iterator, con métodos:

    • Stop()
  • Type map[interface{}]struct{} uSet, con los métodos de ISet.

  • Type struct OrderedPair, con los métodos:

    • Equal(other OrderedPair) bool

-Funciones:

  • NewSet(...Item) ISet

Ejemplos

	requiredClasses := NewSet()
	requiredClasses.Add("Cooking")
	requiredClasses.Add("English")
	requiredClasses.Add("Math")
	requiredClasses.Add("Biology")

	intClasses := NewSet(215, 1285, 7695, 3455)
	scienceClasses := NewSet("Biology", "Chemistry")
	electiveClasses := NewSet()
	electiveClasses.Add("Welding")
	electiveClasses.Add("Music")
	electiveClasses.Add("Automotive")

	bonusClasses := NewSet()
	bonusClasses.Add("Go Programming")
	bonusClasses.Add("Python Programming")

	//Show me all the available classes I can take
	allClasses := requiredClasses.Union(scienceClasses).Union(electiveClasses).Union(bonusClasses).Union(intClasses)
	fmt.Println(allClasses) //Set{Cooking, English, Math, Chemistry, Welding, Biology, Music, Automotive, Go Programming, Python Programming}

	//Is cooking considered a science class?
	fmt.Println(scienceClasses.Contains("Cooking")) //false

	//Show me all classes that are not science classes, since I hate science.
	fmt.Println(allClasses.Difference(scienceClasses)) //Set{Music, Automotive, Go Programming, Python Programming, Cooking, English, Math, Welding}

	//Which science classes are also required classes?
	fmt.Println(scienceClasses.Intersect(requiredClasses)) //Set{Biology}

	//How many bonus classes do you offer?
	fmt.Println(bonusClasses.Cardinality()) //2
	fmt.Println(intClasses.Cardinality())   //2

	//Do you have the following classes? Welding, Automotive and English?
	fmt.Println(allClasses.IsSuperset(set.NewSet("Welding", "Automotive", "English"))) //true

Notas

LICENSE

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0