utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utils defines a set of utility functions and types used across the helium project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountIEC

func ByteCountIEC(b uint64) string

ByteCountIEC returns a string representation of a byte count b, by formatting it as a IEC value.

func ByteCountSI

func ByteCountSI(b uint64) string

ByteCountSI returns a string representation of a byte count b, by formatting it as a SI value.

func GetRandomSliceOfSize

func GetRandomSliceOfSize[T any](t int, s []T) []T

GetRandomSliceOfSize returns a slice containing t random elements from s. The function panics if t > len(s).

func MarshalJSONToFile

func MarshalJSONToFile(s interface{}, filename string) error

MarshalJSONToFile attempts to write s to a file with file name filename, by calling the json.Marshal function.

func SPrintDebugCiphertext

func SPrintDebugCiphertext(ct rlwe.Ciphertext) string

SPrintDebugCiphertext is a debug function for obtaining a short string representation of a ciphertext by hashing its binary representation.

func UnmarshalJSONFromFile

func UnmarshalJSONFromFile(filename string, s interface{}) error

UnmarshalJSONFromFile attempts to load a json file with name filename, and to decode its content into s by calling the json.Unmarshal function.

Types

type Set

type Set[T comparable] map[T]struct{}

Set is a mutable set of elements of type T. Set is not safe for concurrent use.

func GetRandomSetOfSize

func GetRandomSetOfSize[T comparable](t int, s Set[T]) Set[T]

GetRandomSetOfSize returns a set containing t random elements from s. The function panics if t > len(s).

func NewEmptySet

func NewEmptySet[T comparable]() Set[T]

NewEmptySet creates a new empty set.

func NewSet

func NewSet[T comparable](els []T) Set[T]

NewSet creates a new set with the elements els.

func NewSingletonSet

func NewSingletonSet[T comparable](el T) Set[T]

NewSingletonSet creates a new set with a single element el.

func (*Set[T]) Add

func (s *Set[T]) Add(el T)

Add adds an element el to the receiver set.

func (*Set[T]) AddAll

func (s *Set[T]) AddAll(els Set[T])

AddAll adds all elements of set els into the receiver set.

func (Set[T]) Contains

func (s Set[T]) Contains(el T) bool

Contains returns whether an element el is in the receiver set.

func (Set[T]) Copy

func (s Set[T]) Copy() Set[T]

Copy returns a new set containing the elements of the receiver set. It performs a shallow copy of the set elements.

func (Set[T]) Diff

func (s Set[T]) Diff(other Set[T]) Set[T]

Diff returns the set difference between the receiver and other.

func (Set[T]) Disjoint

func (s Set[T]) Disjoint(other Set[T]) bool

Disjoint returns whether the receiver and the other sets have an empty intersection.

func (Set[T]) Elements

func (s Set[T]) Elements() []T

Elements returns the set elements as a slice.

func (Set[T]) Equals

func (s Set[T]) Equals(other Set[T]) bool

Equals returns whether the receiver and other sets are equal.

func (Set[T]) Includes

func (s Set[T]) Includes(other Set[T]) bool

Includes returns whether the other set is a subset of the receiver set.

func (Set[T]) Remove

func (s Set[T]) Remove(els ...T)

Remove removes all elements els from the receiver set.

Directories

Path Synopsis
Package certs provides utility functions for managing certificates.
Package certs provides utility functions for managing certificates.

Jump to

Keyboard shortcuts

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