Debian Codegraph @

cty/set/set.go

raw symbols SCIP
1 package setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
5 )
6
7 // Set is an implementation of the concept of a set: a collection where all
8 // values are conceptually either in or out of the set, but the members are
9 // not ordered.
10 //
11 // This type primarily exists to be the internal type of sets in cty, but
12 // it is considered to be at the same level of abstraction as Go's built in
13 // slice and map collection types, and so should make no cty-specific
14 // assumptions.
15 //
16 // Set operations are not thread safe. It is the caller's responsibility to
17 // provide mutex guarantees where necessary.
18 //
19 // Set operations are not optimized to minimize memory pressure. Mutating
20 // a set will generally create garbage and so should perhaps be avoided in
21 // tight loops where memory pressure is a concern.
22 type Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T any] struct {
23 valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals. map[int][]T
24 rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules. Rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#[T]
25 }
26
27 // NewSet returns an empty set with the membership rules given.
28 func NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().[T any](rules Rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#[T]) Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T] {
29 return Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T]{
30 valsscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#vals.: map[int][]T{},
31 rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules.: rules,
32 }
33 }
34
35 func NewSetFromSlicescip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSetFromSlice().[T any](rules Rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#[T], vals []T) Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T] {
36 s := NewSetscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/NewSet().(rules)
37 for _, v := range vals {
38 s.Addscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Add().(v)
39 }
40 return s
41 }
42
43 func sameRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/sameRules().[T any](s1 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T], s2 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T]) bool {
44 return s1.rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules..SameRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#SameRules.(s2.rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules.)
45 }
46
47 func mustHaveSameRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/mustHaveSameRules().[T any](s1 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T], s2 Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T]) {
48 if !sameRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/sameRules().(s1, s2) {
49 panic(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("incompatible set rules: %#v, %#v", s1.rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules., s2.rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules.))
50 }
51 }
52
53 // HasRules returns true if and only if the receiving set has the given rules
54 // instance as its rules.
55 func (s Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T]) HasRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#HasRules().(rules Rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#[T]) bool {
56 return s.rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules..SameRulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#SameRules.(rules)
57 }
58
59 // Rules returns the receiving set's rules instance.
60 func (s Setscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#[T]) Rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#Rules().() Rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Rules#[T] {
61 return s.rulesscip-go gomod github.com/zclconf/go-cty . `github.com/zclconf/go-cty/cty/set`/Set#rules.
62 }