simple

package
v2.0.0-...-4b7107c Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 5 Imported by: 0

README

simpleSet

Description

A simple golang set because who wants to reinvent wheels all the time when you really just want to solve problems?

Methods

Method Syntax Description
Add() .Add(item any) error Add a item to set. Throw error type check fails
Count() .Count() int Return a count of records
Delete() .Delete(item any) error Delete an existing record
Empty() .Empty() bool Returns boolean true if set empty or set is uninitialized
GetFirst() .GetFirst() any Returns the first record in the set (not always first added)
GetType() .GetType() reflect.Kind Returns the set type
Has() .Has(item any) bool Return true if item exists or false otherwise.
Init() .Init() Initialize the state's internal data structure
List() .List() (result []any) Return a list of items
ListString() .ListString(sort bool) (result []string) Return the set as a list of strings.
TypeCheck() .TypeCheck(item any) bool Return bool true if set empty or of same type

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set - Create map of any to its type

func (*Set) Add

func (set *Set) Add(item any) error

Add - add item to set (all items must be of the same type).

func (*Set) Count

func (set *Set) Count() int

Count - return a count of the records in a set

func (*Set) Delete

func (set *Set) Delete(item interface{}) error

Delete - delete an item from the set

func (*Set) Empty

func (set *Set) Empty() bool

func (*Set) GetFirst

func (set *Set) GetFirst() any

func (*Set) GetType

func (set *Set) GetType() reflect.Kind

GetType - Return the type of the first item (indicating type of the set)

func (*Set) Has

func (set *Set) Has(item any) bool

Has - return true if row exists

func (*Set) Init

func (set *Set) Init()

Init - Initialize the state's internal data structure

func (*Set) List

func (set *Set) List() (result []any)

List - Return a list of items

func (*Set) ListString

func (set *Set) ListString(sortResult bool) (result []string)

ListString - return teh set as a list of strings

func (*Set) TypeCheck

func (set *Set) TypeCheck(item any) bool

TypeCheck - Return whether item is of the same type as the set (empty defaults to true)

type SetMap

type SetMap map[any]misc.NullObjectStruct

Jump to

Keyboard shortcuts

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