interface.go
interface.go - Overview
-
Overview Defines the
BaseLabels
interface, which provides methods for working with a collection of labels. -
Detailed Documentation
BaseLabels
Interface
- Purpose: Defines an interface for interacting with a set of labels (key-value pairs). Each method provides a different way to access, manipulate, or represent the labels.
Len()
- Purpose: Returns the number of labels.
- Returns:
int
- The number of labels.
Swap(i, j int)
- Purpose: Swaps the labels at indices
i
andj
. - Parameters:
i
int: The index of the first label.j
int: The index of the second label.
- Returns: None
Less(i, j int) bool
- Purpose: Compares the labels at indices
i
andj
and returns true if the label ati
is less than the label atj
. - Parameters:
i
int: The index of the first label.j
int: The index of the second label.
- Returns:
bool
- True if the label at indexi
is less than the label at indexj
, false otherwise.
String()
- Purpose: Returns a string representation of the labels.
- Returns:
string
- The string representation of the labels.
Hash()
- Purpose: Calculates and returns a hash value for the labels.
- Returns:
uint64
- The hash value of the labels.
HashForLabels(b []byte, names ...string) (uint64, []byte)
- Purpose: Calculates a hash value for a subset of labels specified by
names
, usingb
as the initial byte slice for the hash. - Parameters:
b
[]byte: The initial byte slice for the hash calculation.names
...string: The names of the labels to include in the hash.
- Returns:
(uint64, []byte)
- The calculated hash value (uint64) and the updated byte slice (used internally for hashing).
Get(name string) string
- Purpose: Retrieves the value of the label with the given name.
- Parameters:
name
string: The name of the label.
- Returns:
string
- The value of the label, or an empty string if the label is not found.
Has(name string) bool
- Purpose: Checks if a label with the given name exists.
- Parameters:
name
string: The name of the label.
- Returns:
bool
- True if the label exists, false otherwise.
Map() map[string]string
- Purpose: Returns a map containing all labels.
- Returns:
map[string]string
- A map where the keys are label names and the values are label values.
Include in Getting Started: NO