selector

package
v1.44.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	Type  Type
	Value string
}

Key is a suitable key for a Selector, since selectors are not otherwise comparable.

type Selector

type Selector struct {
	Type  Type
	Value string
	// contains filtered or unexported fields
}

func Parse

func Parse(errs *perr.List, startPos token.Pos, s string) (Selector, bool)

func (Selector) End

func (s Selector) End() token.Pos

func (Selector) Equals

func (s Selector) Equals(o Selector) bool

Equals reports whether s and o are equal on type and value.

It does not compare the start and end positions.

func (Selector) Key

func (s Selector) Key() Key

Key returns a Key for s.

func (Selector) Pos

func (s Selector) Pos() token.Pos

func (Selector) String

func (s Selector) String() string

func (Selector) ToProto

func (s Selector) ToProto() *meta.Selector

type Set

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

func NewSet

func NewSet(sels ...Selector) Set

func (*Set) Add

func (s *Set) Add(sel Selector) (added bool)

Add adds a selector to the set. It reports whether the selector was added, meaning it reports false iff the set already contained that selector.

Add ensures that the set is sorted.

func (*Set) Contains

func (s *Set) Contains(sel Selector) bool

Contains reports whether the set contains the given selector.

func (*Set) ContainsAny

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

ContainsAny reports whether the set contains any of the selectors in other.

It compares in linear time O(N) where N is the number of selectors in the larger set. It is faster than calling Contains for each selector in other.

func (*Set) ForEach

func (s *Set) ForEach(fn func(Selector))

ForEach calls fn for each selector in the set.

func (*Set) Len

func (s *Set) Len() int

Len returns the number of selectors in the set.

func (*Set) Merge

func (s *Set) Merge(other Set)

Merge adds all the selectors from other to s.

It is equivalent to calling Add for each selector in other.

func (*Set) ToProto

func (s *Set) ToProto() []*meta.Selector

ToProto returns the set as a slice of proto selectors.

type Type

type Type string
const (
	All Type = "all"
	Tag Type = "tag"
)

Jump to

Keyboard shortcuts

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