collections

package
v0.140.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 4 Imported by: 14

Documentation

Overview

Package collections contains common Hugo functionality related to collection handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(to any, from ...any) (any, error)

Append appends from to a slice to and returns the resulting slice. If length of from is one and the only element is a slice of same type as to, it will be appended.

func Slice

func Slice(args ...any) any

Slice returns a slice of all passed arguments.

func StringSliceToInterfaceSlice added in v0.91.0

func StringSliceToInterfaceSlice(ss []string) []any

StringSliceToInterfaceSlice converts ss to []interface{}.

Types

type Grouper

type Grouper interface {
	Group(key any, items any) (any, error)
}

Grouper defines a very generic way to group items by a given key.

type Order added in v0.73.0

type Order interface {
	// Ordinal is a zero-based ordinal that represents the order of an object
	// in a collection.
	Ordinal() int
}

type Slicer

type Slicer interface {
	Slice(items any) (any, error)
}

Slicer defines a very generic way to create a typed slice. This is used in collections.Slice template func to get types such as Pages, PageGroups etc. instead of the less useful []interface{}.

type SortedStringSlice added in v0.111.0

type SortedStringSlice []string

func (SortedStringSlice) Contains added in v0.111.0

func (ss SortedStringSlice) Contains(s string) bool

Contains returns true if s is in ss.

func (SortedStringSlice) Count added in v0.111.0

func (ss SortedStringSlice) Count(s string) int

Count returns the number of times s is in ss.

type Stack added in v0.123.0

type Stack[T any] struct {
	// contains filtered or unexported fields
}

Stack is a simple LIFO stack that is safe for concurrent use.

func NewStack added in v0.123.0

func NewStack[T any]() *Stack[T]

func (*Stack[T]) Drain added in v0.123.0

func (s *Stack[T]) Drain() []T

func (*Stack[T]) DrainMatching added in v0.128.0

func (s *Stack[T]) DrainMatching(predicate func(T) bool) []T

func (*Stack[T]) Len added in v0.123.0

func (s *Stack[T]) Len() int

func (*Stack[T]) Peek added in v0.123.0

func (s *Stack[T]) Peek() (T, bool)

func (*Stack[T]) Pop added in v0.123.0

func (s *Stack[T]) Pop() (T, bool)

func (*Stack[T]) Push added in v0.123.0

func (s *Stack[T]) Push(item T)

Jump to

Keyboard shortcuts

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