api

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 0 Imported by: 0

README

API

  • api.go:
    • type Unit : struct{}
    • var U = Unit{}
  • sets.go:
    type BasicSet[C comparable] interface {
      String() string
      Len() int
      Elements() []C
      Add(elements ...C)
      Contains(elements ...C) bool
      Remove(elements ...C)
    }
    
    type ElementSet[C comparable] interface {
      BasicSet[C]
    
      Union(other ElementSet[C]) ElementSet[C]
      Intersection(other ElementSet[C]) ElementSet[C]
      Difference(other ElementSet[C]) ElementSet[C]
    
      ThreeWay(other ElementSet[C]) [3]ElementSet[C]
    
      UnionWith(elements ...C) ElementSet[C]
      IntersectionWith(elements ...C) ElementSet[C]
      DifferenceWith(elements ...C) ElementSet[C]
    }
    
  • number_types.go:
    type Number interface{ Integer | FloatingPoint }
    type Integer interface { SignedInteger | UnsignedInteger }
    type SignedInteger interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 }
    type UnsignedInteger interface { ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr }
    type FloatingPoint interface{ ~float32 | ~float64 }
    
  • interval.go:
    • type GrowFlags int
    • type Interval[T] interface { ... } [#TODO: Is this needed?]

Documentation

Overview

Package api defines interfaces implemented by library structs and common types.

Index

Constants

This section is empty.

Variables

View Source
var U = Unit{}

U is the unit instance, representing the single instance of the type nothing.

Functions

This section is empty.

Types

type BasicSet added in v0.0.5

type BasicSet[C comparable] interface {
	// String returns the string representation of the set.
	// Example:
	//  { (), (), () }
	String() string
	// Len counts the elements in the set.
	Len() int
	// Elements returns the unique elements of the set.
	Elements() []C
	// Add unique elements to the set.
	// Repeated elements will be discarded.
	Add(elements ...C)
	// Contains checked whether all elements are in the set.
	Contains(elements ...C) bool
	// Remove any existing elements from the set.
	Remove(elements ...C)
}

BasicSet is an interface for a basic implementation of a set of comparables.

type ElementSet added in v0.0.6

type ElementSet[C comparable] interface {
	BasicSet[C]

	Union(other ElementSet[C]) ElementSet[C]
	Intersection(other ElementSet[C]) ElementSet[C]
	Difference(other ElementSet[C]) ElementSet[C]

	ThreeWay(other ElementSet[C]) [3]ElementSet[C]

	UnionWith(elements ...C) ElementSet[C]
	IntersectionWith(elements ...C) ElementSet[C]
	DifferenceWith(elements ...C) ElementSet[C]
}

ElementSet is an interface for a complete implementation of a set of comparables.

type FloatingPoint added in v0.0.5

type FloatingPoint interface{ ~float32 | ~float64 }

type GrowFlags added in v0.0.5

type GrowFlags int
const (
	GROW_BOTH_OVERFLOW_RIGHT GrowFlags = 0
	GROW_LEFT_OVERFLOW_RIGHT GrowFlags = 1
	GROW_RIGHT_OVERFLOW_LEFT GrowFlags = 2
	GROW_BOTH_OVERFLOW_LEFT  GrowFlags = 3
	GROW_NO_OVERFLOW         GrowFlags = 4
)

type Integer added in v0.0.5

type Integer interface {
	SignedInteger | UnsignedInteger
}

type Interval added in v0.0.5

type Interval[T Number] interface {
	Min() T
	Max() T
	Len() T

	IsEmpty() bool
	IsSingleton() bool
	IsCompound() bool

	Enumerate(step T) []T
	Intervals() []Interval[T]

	Contains(value T) bool
	Overlaps(other Interval[T]) bool
	Equals(other Interval[T]) bool

	Union(other Interval[T]) Interval[T]
	Intersection(other Interval[T]) Interval[T]
	Difference(other Interval[T]) Interval[T]

	Resize(newSize T, growMode GrowFlags) Interval[T]
	Scale(scale float64, growMode GrowFlags) Interval[T]
	Translate(offset T, back bool) Interval[T]
}

type Number added in v0.0.5

type Number interface{ Integer | FloatingPoint }

type SignedInteger added in v0.0.5

type SignedInteger interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unit

type Unit = struct{}

Unit represents an empty struct for efficient representation of nothing.

type UnsignedInteger added in v0.0.5

type UnsignedInteger interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Jump to

Keyboard shortcuts

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