demo

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package demo provides code examples used in the ../README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FavWriter

type FavWriter struct {
	IsFav IsFavorite
	W     io.Writer
	Store Store
}

FavWriter is used to filter and write only favorite number

func (*FavWriter) Load

func (d *FavWriter) Load(maxWeight uint32) (map[int]Widget, error)

Load retrieves multiple Widget objects

func (*FavWriter) WriteFavorites

func (d *FavWriter) WriteFavorites(nums []int) error

WriteFavorites iterates through a given list of numbers and writes any favorite number to the given Writer

type Gadget

type Gadget struct {
	Id       int
	WidgetId int
	Color    string
	Weight   uint32
}

Gadget holds the state of a gadget

type IsFavorite

type IsFavorite func(n int) bool

IsFavorite is the function type for a function that determines if a number is a favorite

type Store

type Store interface {
	AllWidgetsIds() ([]int, error)
	GadgetsByWidgetId(widgetId int) ([]Gadget, error)
	LightGadgetsByWidgetId(widgetId int, maxWeight uint32) ([]Gadget, error)
}

Store is the abstraction for Widget and Gadget types

type Widget

type Widget struct {
	Id             int
	GadgetsByColor map[string]Gadget
}

Widget holds the state of a widget

Jump to

Keyboard shortcuts

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