util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AntMatcher

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

AntMatcher is an implementation for Ant-style path patterns.

Standard Ant path matching URLs rules apply :

  • ? matches one character
  • * matches zero or more characters
  • ** matches zero or more directories in a path

Examples

  • "com/t?st.html" — matches "com/test.html" but also "com/tast.html" or "com/txst.html"
  • "com/*.html" — matches all .html files in the com directory
  • "com/**/test.html" — matches all test.html files underneath the com path
  • "com/beamfoundry/**/*.html" — matches all .html files underneath the org/beamfoundry path
  • "org/**/services/bla.html" — matches "org/beamfoundry/services/bla.html" but also "org/beamfoundry/testing/services/bla.html" and "org/services/bla.html"

func (*AntMatcher) Match

func (this *AntMatcher) Match(n []byte) bool

Match() returns whether the n byte slice match the pattern.

TODO: With 1.27 use generic method instead of two methods.

func (*AntMatcher) MatchString

func (this *AntMatcher) MatchString(s string) bool

MatchString() returns whether the s string match the pattern

TODO: With 1.27 use generic method instead of two methods.

func (AntMatcher) New

func (this AntMatcher) New(pattern string) (*AntMatcher, Error)

New() returns optionally and AntMatcher object pointer.

Internally the string pattern is transformed into a regexp.Regexp. In case the regexp compilation fails an github.com/BeamFoundry/rays/pkg/lang.Error will be returned.

func (*AntMatcher) String

func (this *AntMatcher) String() string

String() returns the original string passed to the constructor

type ArrayList added in v0.3.0

type ArrayList[T any] struct {
	AbstractList[T]
}

ArrayList is a resizable-array implementation of the List interface.

func NewArrayList added in v0.3.0

func NewArrayList[T any](elements ...T) *ArrayList[T]

NewArrayList creates a new ArrayList containing the given elements.

func NewArrayListWithCapacity added in v0.3.0

func NewArrayListWithCapacity[T any](capacity int) *ArrayList[T]

NewArrayListWithCapacity creates an empty ArrayList with the specified initial capacity.

func (*ArrayList[T]) Add added in v0.3.0

func (this *ArrayList[T]) Add(elements ...T) bool

Add appends the specified elements to the end of this list. Returns true if this list changed as a result of the call.

func (*ArrayList[T]) AddAll added in v0.3.0

func (this *ArrayList[T]) AddAll(c Collection[T]) bool

AddAll appends all of the elements in the specified collection to the end of this list. Returns true if this list changed as a result of the call.

func (*ArrayList[T]) AddAt added in v0.3.0

func (this *ArrayList[T]) AddAt(index int, element T)

AddAt inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right. Panics with IndexOutOfBoundsError if the index is out of range.

func (*ArrayList[T]) Clear added in v0.3.0

func (this *ArrayList[T]) Clear()

Clear removes all elements from this list.

func (*ArrayList[T]) Contains added in v0.3.0

func (this *ArrayList[T]) Contains(element T) bool

Contains returns true if this list contains the specified element.

func (*ArrayList[T]) ContainsAll added in v0.3.0

func (this *ArrayList[T]) ContainsAll(c Collection[T]) bool

ContainsAll returns true if this list contains all of the elements in the specified collection.

func (*ArrayList[T]) Equals added in v0.3.0

func (this *ArrayList[T]) Equals(c Collection[T]) bool

Equals returns true if the specified collection is equal to this list.

func (*ArrayList[T]) Get added in v0.3.0

func (this *ArrayList[T]) Get(index int) T

Get returns the element at the specified position in this list. Panics with IndexOutOfBoundsError if the index is out of range.

func (*ArrayList[T]) IndexOf added in v0.3.0

func (this *ArrayList[T]) IndexOf(element T) int

IndexOf returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

func (*ArrayList[T]) IsEmpty added in v0.3.0

func (this *ArrayList[T]) IsEmpty() bool

IsEmpty returns true if this list contains no elements.

func (*ArrayList[T]) LastIndexOf added in v0.3.0

func (this *ArrayList[T]) LastIndexOf(element T) int

LastIndexOf returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

func (*ArrayList[T]) MarshalJSON added in v0.3.0

func (this *ArrayList[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ArrayList[T]) Remove added in v0.3.0

func (this *ArrayList[T]) Remove(element T) bool

Remove removes the first occurrence of the specified element from this list, if it is present. Returns true if an element was removed.

func (*ArrayList[T]) RemoveAll added in v0.3.0

func (this *ArrayList[T]) RemoveAll(c Collection[T]) bool

RemoveAll removes all of this list's elements that are also contained in the specified collection. Returns true if this list changed as a result of the call.

func (*ArrayList[T]) RemoveAt added in v0.3.0

func (this *ArrayList[T]) RemoveAt(index int) T

RemoveAt removes the element at the specified position in this list. Shifts any subsequent elements to the left. Returns the element that was removed from the list. Panics with IndexOutOfBoundsError if the index is out of range.

func (*ArrayList[T]) RetainAll added in v0.3.0

func (this *ArrayList[T]) RetainAll(c Collection[T]) bool

RetainAll retains only the elements in this list that are contained in the specified collection. Returns true if this list changed as a result of the call.

func (*ArrayList[T]) Scan added in v0.3.0

func (this *ArrayList[T]) Scan(src any) error

Scan implements sql.Scanner.

func (*ArrayList[T]) Seq added in v0.3.0

func (this *ArrayList[T]) Seq() iter.Seq[T]

Seq returns an iterator sequence over the elements in this list.

func (*ArrayList[T]) Set added in v0.3.0

func (this *ArrayList[T]) Set(index int, element T) T

Set replaces the element at the specified position in this list with the specified element. Returns the element previously at the specified position. Panics with IndexOutOfBoundsError if the index is out of range.

func (*ArrayList[T]) Size added in v0.3.0

func (this *ArrayList[T]) Size() int

Size returns the number of elements in this list.

func (*ArrayList[T]) Stream added in v0.3.0

func (this *ArrayList[T]) Stream() Stream[T]

Stream returns a sequential Stream with this list as its source.

func (*ArrayList[T]) SubList added in v0.3.0

func (this *ArrayList[T]) SubList(fromIndex, toIndex int) List[T]

SubList returns an independent copy of the portion of this list between fromIndex, inclusive, and toIndex, exclusive. Changes to the returned list do not affect the original list. Panics with IndexOutOfBoundsError if the indices are out of range.

func (*ArrayList[T]) ToSlice added in v0.3.0

func (this *ArrayList[T]) ToSlice() []T

ToSlice returns a copy of the underlying slice.

func (*ArrayList[T]) UnmarshalJSON added in v0.3.0

func (this *ArrayList[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*ArrayList[T]) Value added in v0.3.0

func (this *ArrayList[T]) Value() (driver.Value, error)

Value implements driver.Valuer.

type CaseUtils

type CaseUtils string

CaseUtils is a type redefinition of "string"

As such it can be constructed using the type name as a function.

Example :

CaseUtils("test").UpperCase().String() // Returns "TEST"

func (CaseUtils) Capitalize

func (this CaseUtils) Capitalize() CaseUtils

Capitalize() will change the first letter to uppercase case. No other letters are changed.

func (CaseUtils) LowerCase

func (this CaseUtils) LowerCase() CaseUtils

LowerCase() will convert all the characters to lower case

func (CaseUtils) SnakeCase

func (this CaseUtils) SnakeCase() CaseUtils

SnakeCase() will convert this string to a snake case format

func (CaseUtils) String

func (this CaseUtils) String() string

String() Returns a string version of this CaseUtils

func (CaseUtils) ToString

func (this CaseUtils) ToString() String

ToString() Returns a github.com/BeamFoundry/rays/pkg/lang.String version of this CaseUtils

func (CaseUtils) Uncapitalize

func (this CaseUtils) Uncapitalize() CaseUtils

Capitalize() will change the first letter to lowercase case. No other letters are changed.

func (CaseUtils) UpperCase

func (this CaseUtils) UpperCase() CaseUtils

UpperCase() will convert all the characters to upper case

type ConcurrentHashMap

type ConcurrentHashMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

ConcurrentHashMap is a [Map] implementation that is thread-safe

Internally it's just a [HasmMap] combined to a sync.RWMutex

TODO: Review lock.

func (*ConcurrentHashMap[K, V]) Clear

func (this *ConcurrentHashMap[K, V]) Clear()

Clear() implements [Map.Clear]

func (*ConcurrentHashMap[K, V]) ContainsKey

func (this *ConcurrentHashMap[K, V]) ContainsKey(key K) bool

ContainsKey() implements [Map.ContainsKey]

func (*ConcurrentHashMap[K, V]) Delete

func (this *ConcurrentHashMap[K, V]) Delete(f func(key K, val V) bool)

Delete() implements [Map.Delete]

func (*ConcurrentHashMap[K, V]) Equals

func (this *ConcurrentHashMap[K, V]) Equals(m Map[K, V]) bool

Equals() implements [Map.Equals].

func (*ConcurrentHashMap[K, V]) Get

func (this *ConcurrentHashMap[K, V]) Get(key K) Optional[V]

Get() implements [Map.Get]

func (*ConcurrentHashMap[K, V]) IsEmpty

func (this *ConcurrentHashMap[K, V]) IsEmpty() bool

IsEmpty() implements [Map.IsEmpty]

func (*ConcurrentHashMap[K, V]) Iterator

func (this *ConcurrentHashMap[K, V]) Iterator() iter.Seq2[K, V]

Iterator() implements [Map.Iterator]

func (*ConcurrentHashMap[K, V]) Map

func (this *ConcurrentHashMap[K, V]) Map() map[K]V

Map() implements [Map.Map]

func (*ConcurrentHashMap[K, V]) MarshalJSON

func (this *ConcurrentHashMap[K, V]) MarshalJSON() ([]byte, error)

MashalJSON() implements json.Marshaler

func (*ConcurrentHashMap[K, V]) Merge

func (this *ConcurrentHashMap[K, V]) Merge(m Map[K, V])

Merge() implements [Map.Merge].

func (ConcurrentHashMap[K, V]) New

func (this ConcurrentHashMap[K, V]) New() *ConcurrentHashMap[K, V]

New() creates a new ConcurrentHashMap

func (*ConcurrentHashMap[K, V]) Put

func (this *ConcurrentHashMap[K, V]) Put(key K, val V) Map[K, V]

Put() implements [Map.Put]

func (*ConcurrentHashMap[K, V]) PutAll

func (this *ConcurrentHashMap[K, V]) PutAll(m Map[K, V]) Map[K, V]

PutAll() implements [Map.PutAll]

func (*ConcurrentHashMap[K, V]) Remove

func (this *ConcurrentHashMap[K, V]) Remove(key K) Optional[V]

Remove() implements [Map.Remove]

func (*ConcurrentHashMap[K, V]) Size

func (this *ConcurrentHashMap[K, V]) Size() int

Size() implements [Map.Size]

func (*ConcurrentHashMap[K, V]) UnmarshalJSON

func (this *ConcurrentHashMap[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON() implements json.Unmarshal

type HashMap

type HashMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

HashMap is default [Map] implementation

func NewHashMap

func NewHashMap[K comparable, V any]() HashMap[K, V]

NewHashMap() creates a new, empty HashMap

func NewHashMapFor

func NewHashMapFor[K comparable, V any](m map[K]V) HashMap[K, V]

NewHashMapFor() encapsulate an existing map as a HashMap

func NewHashMapFrom

func NewHashMapFrom[K comparable, V any](m map[K]V) HashMap[K, V]

NewHashMapFrom() encapsulate an existing map as a HashMap and clones it.

func (HashMap[K, V]) Clear

func (this HashMap[K, V]) Clear()

Clear() implements [Map.Clear]

func (HashMap[K, V]) Clone

func (this HashMap[K, V]) Clone() HashMap[K, V]

Clone() clones the current map

func (HashMap[K, V]) ContainsKey

func (this HashMap[K, V]) ContainsKey(key K) bool

ContainsKey() implements [Map.ContainsKey]

func (HashMap[K, V]) Delete

func (this HashMap[K, V]) Delete(f func(key K, val V) bool)

Delete() implements [Map.Delete]

func (HashMap[K, V]) Equals

func (this HashMap[K, V]) Equals(m Map[K, V]) bool

Equals() implements [Map.Equals].

It does it using reflect.DeepEqual

func (HashMap[K, V]) Get

func (this HashMap[K, V]) Get(key K) Optional[V]

Get() implements [Map.Get]

func (HashMap[K, V]) IsEmpty

func (this HashMap[K, V]) IsEmpty() bool

IsEmpty() implements [Map.IsEmpty]

func (HashMap[K, V]) Iterator

func (this HashMap[K, V]) Iterator() iter.Seq2[K, V]

Iterator() implements [Map.Iterator]

func (HashMap[K, V]) Map

func (this HashMap[K, V]) Map() map[K]V

Map() implements [Map.Map]

func (HashMap[K, V]) MarshalJSON

func (this HashMap[K, V]) MarshalJSON() ([]byte, error)

MashalJSON() implements json.Marshaler

func (HashMap[K, V]) Merge

func (this HashMap[K, V]) Merge(m Map[K, V])

Merge() implements [Map.Merge].

func (HashMap[K, V]) Put

func (this HashMap[K, V]) Put(key K, val V) Map[K, V]

Put() implements [Map.Put]

func (HashMap[K, V]) PutAll

func (this HashMap[K, V]) PutAll(m Map[K, V]) Map[K, V]

PutAll() implements [Map.PutAll]

func (HashMap[K, V]) Remove

func (this HashMap[K, V]) Remove(key K) Optional[V]

Remove() implements [Map.Remove]

func (HashMap[K, V]) Size

func (this HashMap[K, V]) Size() int

Size() implements [Map.Size]

func (HashMap[K, V]) UnmarshalJSON

func (this HashMap[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON() implements json.Unmarshal

type HashSet added in v0.3.0

type HashSet[T comparable] struct {
	AbstractSet[T]
}

HashSet is a hash table based implementation of the Set interface.

func NewHashSet added in v0.3.0

func NewHashSet[T comparable](elements ...T) *HashSet[T]

NewHashSet creates a new HashSet containing the given elements.

func NewHashSetWithCapacity added in v0.3.0

func NewHashSetWithCapacity[T comparable](capacity int) *HashSet[T]

NewHashSetWithCapacity creates an empty HashSet with the specified initial capacity.

func (*HashSet[T]) Add added in v0.3.0

func (this *HashSet[T]) Add(elements ...T) bool

Add adds the specified elements to this set. Returns true if this set changed as a result of the call.

func (*HashSet[T]) AddAll added in v0.3.0

func (this *HashSet[T]) AddAll(c Collection[T]) bool

AddAll adds all of the elements in the specified collection to this set. Returns true if this set changed as a result of the call.

func (*HashSet[T]) Clear added in v0.3.0

func (this *HashSet[T]) Clear()

Clear removes all elements from this set.

func (*HashSet[T]) Contains added in v0.3.0

func (this *HashSet[T]) Contains(element T) bool

Contains returns true if this set contains the specified element.

func (*HashSet[T]) ContainsAll added in v0.3.0

func (this *HashSet[T]) ContainsAll(c Collection[T]) bool

ContainsAll returns true if this set contains all of the elements in the specified collection.

func (*HashSet[T]) Equals added in v0.3.0

func (this *HashSet[T]) Equals(c Collection[T]) bool

Equals returns true if the specified collection is equal to this set.

func (*HashSet[T]) IsEmpty added in v0.3.0

func (this *HashSet[T]) IsEmpty() bool

IsEmpty returns true if this set contains no elements.

func (*HashSet[T]) MarshalJSON added in v0.3.0

func (this *HashSet[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*HashSet[T]) Remove added in v0.3.0

func (this *HashSet[T]) Remove(element T) bool

Remove removes the specified element from this set, if it is present. Returns true if an element was removed.

func (*HashSet[T]) RemoveAll added in v0.3.0

func (this *HashSet[T]) RemoveAll(c Collection[T]) bool

RemoveAll removes all of this set's elements that are also contained in the specified collection. Returns true if this set changed as a result of the call.

func (*HashSet[T]) RetainAll added in v0.3.0

func (this *HashSet[T]) RetainAll(c Collection[T]) bool

RetainAll retains only the elements in this set that are contained in the specified collection. Returns true if this set changed as a result of the call.

func (*HashSet[T]) Scan added in v0.3.0

func (this *HashSet[T]) Scan(src any) error

Scan implements sql.Scanner.

func (*HashSet[T]) Seq added in v0.3.0

func (this *HashSet[T]) Seq() iter.Seq[T]

Seq returns an iterator sequence over the elements in this set.

func (*HashSet[T]) Size added in v0.3.0

func (this *HashSet[T]) Size() int

Size returns the number of elements in this set.

func (*HashSet[T]) Stream added in v0.3.0

func (this *HashSet[T]) Stream() Stream[T]

Stream returns a sequential Stream with this set as its source.

func (*HashSet[T]) ToSlice added in v0.3.0

func (this *HashSet[T]) ToSlice() []T

ToSlice returns a slice containing all elements in this set.

func (*HashSet[T]) UnmarshalJSON added in v0.3.0

func (this *HashSet[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*HashSet[T]) Value added in v0.3.0

func (this *HashSet[T]) Value() (driver.Value, error)

Value implements driver.Valuer.

Directories

Path Synopsis
Package stream provides a lazy, thread-safe, expressive stream processing framework inspired by Java 8 streams and backed by Go iterators (iter.Seq).
Package stream provides a lazy, thread-safe, expressive stream processing framework inspired by Java 8 streams and backed by Go iterators (iter.Seq).

Jump to

Keyboard shortcuts

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