Documentation
¶
Overview ¶
Package utils defines a set of utility functions and types used across the helium project.
Index ¶
- func ByteCountIEC(b uint64) string
- func ByteCountSI(b uint64) string
- func GetRandomSliceOfSize[T any](t int, s []T) []T
- func MarshalJSONToFile(s interface{}, filename string) error
- func SPrintDebugCiphertext(ct rlwe.Ciphertext) string
- func UnmarshalJSONFromFile(filename string, s interface{}) error
- type Set
- func (s *Set[T]) Add(el T)
- func (s *Set[T]) AddAll(els Set[T])
- func (s Set[T]) Contains(el T) bool
- func (s Set[T]) Copy() Set[T]
- func (s Set[T]) Diff(other Set[T]) Set[T]
- func (s Set[T]) Disjoint(other Set[T]) bool
- func (s Set[T]) Elements() []T
- func (s Set[T]) Equals(other Set[T]) bool
- func (s Set[T]) Includes(other Set[T]) bool
- func (s Set[T]) Remove(els ...T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteCountIEC ¶
ByteCountIEC returns a string representation of a byte count b, by formatting it as a IEC value.
func ByteCountSI ¶
ByteCountSI returns a string representation of a byte count b, by formatting it as a SI value.
func GetRandomSliceOfSize ¶
GetRandomSliceOfSize returns a slice containing t random elements from s. The function panics if t > len(s).
func MarshalJSONToFile ¶
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 ¶
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 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]) Copy ¶
Copy returns a new set containing the elements of the receiver set. It performs a shallow copy of the set elements.
func (Set[T]) Disjoint ¶
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.