package collections
import "github.com/gohugoio/hugo/common/collections"
Package collections contains common Hugo functionality related to collection handling.
Index ¶
- func Append(to any, from ...any) (any, error)
- func Slice(args ...any) any
- func StringSliceToInterfaceSlice(ss []string) []any
- type Grouper
- type Order
- type Slicer
- type SortedStringSlice
- type Stack
Functions ¶
func Append ¶
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 ¶
Slice returns a slice of all passed arguments.
func StringSliceToInterfaceSlice ¶
StringSliceToInterfaceSlice converts ss to []interface{}.
Types ¶
type Grouper ¶
Grouper defines a very generic way to group items by a given key.
type Order ¶
type Order interface { // Ordinal is a zero-based ordinal that represents the order of an object // in a collection. Ordinal() int }
type Slicer ¶
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 ¶
type SortedStringSlice []string
func (SortedStringSlice) Contains ¶
func (ss SortedStringSlice) Contains(s string) bool
Contains returns true if s is in ss.
func (SortedStringSlice) Count ¶
func (ss SortedStringSlice) Count(s string) int
Count returns the number of times s is in ss.
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
Stack is a simple LIFO stack that is safe for concurrent use.
func NewStack ¶
func (*Stack[T]) Drain ¶
func (s *Stack[T]) Drain() []T
func (*Stack[T]) DrainMatching ¶
func (*Stack[T]) Len ¶
func (*Stack[T]) Peek ¶
func (*Stack[T]) Pop ¶
func (*Stack[T]) Push ¶
func (s *Stack[T]) Push(item T)
Source Files ¶
append.go collections.go order.go slice.go stack.go
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 13 hours ago –
Tools for package owners.