types

package
v0.0.0-...-1ac790f Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

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

Bool is a bool.

func NewBool

func NewBool() *Bool

NewBool creates a new bool initialized to false.

Returns:

  • *Bool: The new bool. Never returns nil.

func (*Bool) Clean

func (b *Bool) Clean()

Clean implements the pkg.Type interface.

func (*Bool) DeepCopy

func (b *Bool) DeepCopy() pkg.Type

DeepCopy implements the pkg.Type interface.

func (*Bool) Each

func (b *Bool) Each() iter.Seq[*Bool]

Each creates an iterator that iterates over the bool.

Returns:

  • iter.Seq[*Bool]: The iterator. Never returns nil.

The iterator always returns until a break, return statement is reached, or the value given by the iterator is set to false.

func (*Bool) Ensure

func (b *Bool) Ensure()

Ensure implements the pkg.Type interface.

func (*Bool) Equals

func (b *Bool) Equals(other pkg.Type) bool

Equals implements the pkg.Type interface.

Two bools are equal if they have the same value and are both bools.

func (*Bool) Set

func (b *Bool) Set(value bool)

Set sets the bool value.

Parameters:

  • value: The new value.

func (*Bool) String

func (b *Bool) String() string

String implements the pkg.Type interface.

func (Bool) Value

func (b Bool) Value() bool

Value returns the bool value.

Returns:

  • bool: The bool value.

func (*Bool) WithValue

func (b *Bool) WithValue(value bool) *Bool

WithValue creates a new bool with the given value.

Parameters:

  • value: The value.

Returns:

  • *Bool: The new bool. Never returns nil.

type Enum

type Enum[T Enumer] struct {
	// contains filtered or unexported fields
}

Enum is an enum.

func NewEnum

func NewEnum[T Enumer](value T) *Enum[T]

NewEnum creates a new enum.

Parameters:

  • value: The value.

Returns:

  • *Enum: The new enum. Never returns nil.

func (*Enum[T]) Clean

func (e *Enum[T]) Clean()

Clean implements the pkg.Type interface.

func (*Enum[T]) DeepCopy

func (e *Enum[T]) DeepCopy() pkg.Type

DeepCopy implements the pkg.Type interface.

func (*Enum[T]) Ensure

func (e *Enum[T]) Ensure()

Ensure implements the pkg.Type interface.

func (*Enum[T]) Equals

func (e *Enum[T]) Equals(other pkg.Type) bool

Equals implements the pkg.Type interface.

Two enums are equal if they have the same value and are both enums.

func (*Enum[T]) Set

func (e *Enum[T]) Set(value T)

Set sets the enum value.

Parameters:

  • value: The new value.

func (*Enum[T]) String

func (e *Enum[T]) String() string

String implements the pkg.Type interface.

func (Enum[T]) Value

func (e Enum[T]) Value() T

Value returns the enum value.

Returns:

  • T: The enum value.

type Enumer

type Enumer interface {
	~int

	// String returns the literal representation of the enum value.
	//
	// Returns:
	//   - string: The literal representation of the enum value.
	String() string
}

type Int

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

Int is an index.

func NewInt

func NewInt() *Int

NewIndex creates a new index.

Returns:

  • *Int: The new index. Never returns nil.

func (*Int) Clean

func (idx *Int) Clean()

Clean implements the pkg.Type interface.

func (*Int) DeepCopy

func (idx *Int) DeepCopy() pkg.Type

DeepCopy implements the pkg.Type interface.

func (*Int) Ensure

func (idx *Int) Ensure()

Ensure implements the pkg.Type interface.

func (*Int) Equals

func (idx *Int) Equals(other pkg.Type) bool

Equals implements the pkg.Type interface.

Two indexes are equal if they have the same value; regardless of the max value.

func (*Int) Set

func (idx *Int) Set(value int)

Set sets the index value.

Parameters:

  • value: The new value.

func (*Int) String

func (idx *Int) String() string

String implements the fmt.Stringer interface.

func (Int) Value

func (idx Int) Value() int

Value returns the index value.

Returns:

  • int: The index value.

func (*Int) WithValue

func (idx *Int) WithValue(value int) *Int

WithValue creates a new index with the given value.

Parameters:

  • value: The value.

Returns:

  • *Int: The new index. Never returns nil.

type Set

type Set[T pkg.Type] struct {
	// contains filtered or unexported fields
}

Set is a set.

func NewSet

func NewSet[T pkg.Type]() *Set[T]

NewSet creates a new empty set.

Returns:

  • *Set: The new set. Never returns nil.

func (*Set[T]) Add

func (s *Set[T]) Add(elem T) bool

Add adds an element to the set. If the element is already in the set, this method does nothing.

Parameters:

  • elem: The element to add.

Returns:

  • bool: True if the element was added, false otherwise.

func (*Set[T]) Clean

func (s *Set[T]) Clean()

Clean implements the pkg.Type interface.

func (*Set[T]) DeepCopy

func (s *Set[T]) DeepCopy() pkg.Type

DeepCopy implements the pkg.Type interface.

func (Set[T]) Each

func (s Set[T]) Each() iter.Seq[T]

Each returns an iterator that iterates over all elements in the set.

Returns:

  • iter.Seq[T]: The iterator. Never returns nil.

func (*Set[T]) Ensure

func (s *Set[T]) Ensure()

Ensure implements the pkg.Type interface.

func (*Set[T]) Equals

func (s *Set[T]) Equals(other pkg.Type) bool

Equals implements the pkg.Type interface.

Two sets are equal if they have the same values.

func (Set[T]) Has

func (s Set[T]) Has(elem T) bool

Has checks whether the set contains the given element.

Parameters:

  • elem: The element to check.

Returns:

  • bool: True if the set contains the element, false otherwise.

func (Set[T]) IsEmpty

func (s Set[T]) IsEmpty() bool

IsEmpty checks whether the set is empty.

Returns:

  • bool: True if the set is empty, false otherwise.

func (*Set[T]) Reset

func (s *Set[T]) Reset()

Reset removes all elements from the set.

func (Set[T]) Size

func (s Set[T]) Size() int

Size returns the number of elements in the set.

Returns:

  • int: The number of elements in the set.

func (*Set[T]) String

func (s *Set[T]) String() string

String implements the fmt.Stringer interface.

func (*Set[T]) Union

func (s *Set[T]) Union(other *Set[T]) int

Union adds all elements from another set to the set.

Parameters:

  • other: The other set to add.

Returns:

  • int: The number of elements added.

func (*Set[T]) WithValue

func (s *Set[T]) WithValue(slice []T) *Set[T]

WithValue set the values of the set.

Parameters:

  • slice: The slice.

Returns:

  • *Set: The new set. Never returns nil.

type Wrap

type Wrap[T comparable] struct {
	// contains filtered or unexported fields
}

Wrap is a wrapper.

func NewWrap

func NewWrap[T comparable](value T) *Wrap[T]

NewWrap creates a new wrap.

Parameters:

  • value: The value to wrap.

Returns:

  • *Wrap: The new wrap. Never returns nil.

func (*Wrap[T]) Clean

func (w *Wrap[T]) Clean()

Clean implements the pkg.Type interface.

func (*Wrap[T]) DeepCopy

func (w *Wrap[T]) DeepCopy() pkg.Type

DeepCopy implements the pkg.Type interface.

func (*Wrap[T]) Ensure

func (w *Wrap[T]) Ensure()

Ensure implements the pkg.Type interface.

func (*Wrap[T]) Equals

func (w *Wrap[T]) Equals(other pkg.Type) bool

Equals implements the pkg.Type interface.

Two wraps are equal if they have the same value adn are both wraps.

func (*Wrap[T]) Set

func (w *Wrap[T]) Set(value T)

Set sets the wrapped value.

Parameters:

  • value: The new value.

func (*Wrap[T]) String

func (w *Wrap[T]) String() string

String implements the fmt.Stringer interface.

func (Wrap[T]) Value

func (w Wrap[T]) Value() T

Value returns the wrapped value.

Returns:

  • T: The wrapped value.

Jump to

Keyboard shortcuts

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