guid

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare added in v0.5.0

func Compare(a, b Guid) int

Compare returns an integer comparing two Guid values. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func Equal added in v0.5.0

func Equal(a, b Guid) bool

Equal returns true if the a and b Guid values are equal.

Types

type Guid

type Guid [16]byte

Guid is a standard 128-bit UUID value (16-bytes) that can handle alternate wire serialization encodings.

var Empty Guid = Guid{}

Empty is a Guid with a zero value.

func FromBytes

func FromBytes(data []byte, swapEndianness bool) (Guid, error)

FromBytes creates a new Guid from a byte slice. Only first 16 bytes of slice are used. Returns an error if slice length is less than 16. Bytes are copied from the slice.

func New

func New() Guid

New creates a new random Guid value.

func Parse

func Parse(s string) (Guid, error)

Parse decodes a Guid value from a string.

func (Guid) Compare added in v0.5.0

func (g Guid) Compare(other Guid) int

Compare returns an integer comparing this Guid (g) to other Guid. The result will be 0 if g==other, -1 if this g < other, and +1 if g > other.

func (Guid) Components added in v0.5.0

func (g Guid) Components() (a uint32, b, c uint16, d [8]byte)

Components gets the Guid value as its constituent components.

func (Guid) Equal added in v0.5.0

func (g Guid) Equal(other Guid) bool

Equal returns true if this Guid and other Guid values are equal.

func (Guid) IsZero added in v0.3.0

func (g Guid) IsZero() bool

IsZero determines if the Guid value is its zero value, i.e., empty.

func (Guid) String

func (g Guid) String() string

String returns the string form of a Guid, i.e., {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}.

func (Guid) ToBytes added in v0.5.0

func (g Guid) ToBytes(swapEndianness bool) []byte

ToBytes creates a byte slice from a Guid.

type HashSet

type HashSet map[Guid]void

HashSet represents a distinct collection of Guid values, i.e., a set. A HashSet is not sorted and will not contain duplicate elements. The methods of the HashSet are not intrinsically thread-safe procedures, to guarantee thread safety, you should initiate a lock before calling a method.

func NewHashSet

func NewHashSet(items []Guid) HashSet

NewHashSet creates a new set containing all elements in the specified slice. Returns a new HashSet that contain the specified slice items.

func (HashSet) Add

func (hs HashSet) Add(item Guid) bool

Add adds the specified element to a set. Returns true if item was added to the set; otherwise, false.

func (HashSet) Clear

func (hs HashSet) Clear()

Clear removes all elements from a set.

func (HashSet) Contains

func (hs HashSet) Contains(item Guid) bool

Contains determines whether a set contains the specified element. Returns true if the set contains the specified element; otherwise, false.

func (HashSet) ExceptWith

func (hs HashSet) ExceptWith(other []Guid)

ExceptWith removes all elements in the specified slice from the current set.

func (HashSet) ExceptWithSet

func (hs HashSet) ExceptWithSet(other HashSet)

ExceptWithSet removes all elements in the specified set from the current set.

func (HashSet) IntersectWith

func (hs HashSet) IntersectWith(other []Guid)

IntersectWith modifies the current set to contain only elements that are present in the set and in the specified slice.

func (HashSet) IntersectWithSet

func (hs HashSet) IntersectWithSet(other HashSet)

IntersectWithSet modifies the current set to contain only elements that are present in the set and in the specified set.

func (HashSet) IsEmpty

func (hs HashSet) IsEmpty() bool

IsEmpty determines if set contains no elements. Returns true if the set is empty, i.e., has a length of zero; otherwise, false.

func (HashSet) IsProperSubsetOf

func (hs HashSet) IsProperSubsetOf(other []Guid) bool

IsProperSubsetOf determines whether a set is a proper subset of the specified slice. Returns true if the set is a proper subset of other slice items; otherwise, false.

func (HashSet) IsProperSubsetOfSet

func (hs HashSet) IsProperSubsetOfSet(other HashSet) bool

IsProperSubsetOfSet determines whether a set is a proper subset of the specified set. Returns true if the set is a proper subset of other set; otherwise, false.

func (HashSet) IsProperSupersetOf

func (hs HashSet) IsProperSupersetOf(other []Guid) bool

IsProperSupersetOf determines whether a set is a proper superset of the specified slice. Returns true if the set is a proper superset of other slice items; otherwise, false.

func (HashSet) IsProperSupersetOfSet

func (hs HashSet) IsProperSupersetOfSet(other HashSet) bool

IsProperSupersetOfSet determines whether a set is a proper superset of the specified set. Returns true if the set is a proper superset of other set; otherwise, false.

func (HashSet) IsSubsetOf

func (hs HashSet) IsSubsetOf(other []Guid) bool

IsSubsetOf determines whether a set is a subset of the specified slice. Returns true if the set is a subset of other slice items; otherwise, false.

func (HashSet) IsSubsetOfSet

func (hs HashSet) IsSubsetOfSet(other HashSet) bool

IsSubsetOfSet determines whether a set is a subset of the specified set. Returns true if the set is a subset of other set; otherwise, false.

func (HashSet) IsSupersetOf

func (hs HashSet) IsSupersetOf(other []Guid) bool

IsSupersetOf determines whether a set is a superset of the specified slice. Returns true if the set is a superset of other slice items; otherwise, false.

func (HashSet) IsSupersetOfSet

func (hs HashSet) IsSupersetOfSet(other HashSet) bool

IsSupersetOfSet determines whether a set is a superset of the specified set. Returns true if the set is a superset of other set; otherwise, false.

func (HashSet) Keys

func (hs HashSet) Keys() []Guid

Keys copies the elements of a set to a slice. Returns a slice containing the elements of the set.

func (HashSet) Overlaps

func (hs HashSet) Overlaps(other []Guid) bool

Overlaps determines whether the current set and a specified slice share common elements. Returns true if the current set and other slice items share at least one common element; otherwise, false.

func (HashSet) OverlapsSet

func (hs HashSet) OverlapsSet(other HashSet) bool

OverlapsSet determines whether the current set and a specified set share common elements. Returns true if the current set and other set share at least one common element; otherwise, false.

func (HashSet) Remove

func (hs HashSet) Remove(item Guid) bool

Remove removes the specified element from a set. Returns true if item was removed from the set; otherwise, false.

func (HashSet) RemoveWhere

func (hs HashSet) RemoveWhere(predicate func(Guid) bool) int

RemoveWhere removes all elements that match the conditions defined by the specified predicate from a set. Returns number of elements that were removed from the set.

func (HashSet) SetEquals

func (hs HashSet) SetEquals(other []Guid) bool

SetEquals determines whether a set and the specified slice contain the same elements. Returns true if the set is equal to other slice items; otherwise, false.

func (HashSet) SetEqualsSet

func (hs HashSet) SetEqualsSet(other HashSet) bool

SetEqualsSet determines whether a set and the specified set contain the same elements. Returns true if the set is equal to other set; otherwise, false.

func (HashSet) SymmetricExceptWith

func (hs HashSet) SymmetricExceptWith(other []Guid)

SymmetricExceptWith modifies the current set to contain only elements that are present either in the set or in the specified slice, but not both.

func (HashSet) SymmetricExceptWithSet

func (hs HashSet) SymmetricExceptWithSet(other HashSet)

SymmetricExceptWithSet modifies the current set to contain only elements that are present either in the set or in the specified set, but not both.

func (HashSet) UnionWith

func (hs HashSet) UnionWith(other []Guid)

UnionWith modifies the current set to contain all elements that are present in the set, the specified slice, or both.

func (HashSet) UnionWithSet

func (hs HashSet) UnionWithSet(other HashSet)

UnionWithSet modifies the current set to contain all elements that are present in the set, the specified set, or both.

Jump to

Keyboard shortcuts

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