sort

package
v1.0.25 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByFieldIndex

func ByFieldIndex(n FieldIndex) func(i interface{}) interface{}

Order by the field

func ByHost

func ByHost() func(i interface{}) interface{}

Order by Host.Project key

func ByKey

func ByKey() func(i interface{}) interface{}

Order by GroupBy key

func ByLen

func ByLen() func(i interface{}) interface{}

Order by count

func FieldIndexValue

func FieldIndexValue(i FieldIndex, v interface{}) interface{}

Get actual value of struct field by its index

func FromChannelQuery

func FromChannelQuery(ch chan interface{}, opt *Options) linq.Query

func GroupBy

func GroupBy(groupBy FieldIndex) (func(i interface{}) interface{}, func(i interface{}) interface{})

func JsonFieldIndexTree

func JsonFieldIndexTree(v interface{}) *radix.Tree

Create a radix tree of struct fields' json tags and their indices

func OrderBy

func OrderBy(groupBy, orderBy FieldIndex) func(i interface{}) interface{}

func ValidFieldValue

func ValidFieldValue(t *radix.Tree, keys []string, v interface{}) interface{}

Get actual value of any valid struct field in _keys_ slice Panic if all fields are invalid or not found

Types

type Cached

type Cached bool

func (Cached) String

func (c Cached) String() string

type Element

type Element struct {
	Host   *client.Host
	Struct interface{}
	Cached Cached
}

type Elements

type Elements []interface{}

func (Elements) Cached

func (e Elements) Cached() (cached Cached)

func (Elements) Hosts

func (e Elements) Hosts() client.Hosts

func (Elements) Typed

func (e Elements) Typed() []Element

type FieldIndex

type FieldIndex []int

Represents an index of struct field for (reflect.Value).FieldByIndex func

func (FieldIndex) Equal

func (f FieldIndex) Equal(other FieldIndex) bool

Check equality of FieldIndex slices

func (FieldIndex) Negative

func (f FieldIndex) Negative() bool

Check if struct really has a field (it must have positive indices)

type Options

type Options struct {
	SortBy, GroupBy string

	OrderBy    []string
	StructType interface{}
}

type Result

type Result struct {
	Count    int
	Key      string
	Elements Elements
	Cached   Cached
}

func FromChannel

func FromChannel(ch chan interface{}, opt *Options) (results []Result)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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