collections

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Elements []types.Object
}

Array represents a dynamic array of objects

func NewArray

func NewArray() *Array

NewArray creates a new empty array

func NewArrayWithElements

func NewArrayWithElements(elements []types.Object) *Array

NewArrayWithElements creates a new array with the given elements

func (*Array) Append

func (a *Array) Append(value types.Object)

Append adds an element to the end of the array

func (*Array) Clear

func (a *Array) Clear()

Clear removes all elements from the array

func (*Array) Equals

func (a *Array) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Array) Get

func (a *Array) Get(index int) types.Object

Get returns the element at the given index

func (*Array) Insert

func (a *Array) Insert(index int, value types.Object)

Insert inserts an element at the given index

func (*Array) Len

func (a *Array) Len() int

Len returns the number of elements in the array

func (*Array) Remove

func (a *Array) Remove(index int) types.Object

Remove removes and returns the element at the given index

func (*Array) Set

func (a *Array) Set(index int, value types.Object)

Set sets the element at the given index

func (*Array) ToStr

func (a *Array) ToStr() string

ToStr implements types.Object interface

func (*Array) TypeCode

func (a *Array) TypeCode() uint8

TypeCode implements types.Object interface

func (*Array) TypeName

func (a *Array) TypeName() string

TypeName implements types.Object interface

type Map

type Map struct {
	Entries map[string]types.Object
}

Map represents an unordered key-value map

func NewMap

func NewMap() *Map

NewMap creates a new empty map

func (*Map) Clear

func (m *Map) Clear()

Clear removes all entries from the map

func (*Map) Delete

func (m *Map) Delete(key string) types.Object

Delete removes the key from the map

func (*Map) Equals

func (m *Map) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Map) Get

func (m *Map) Get(key string) types.Object

Get returns the value for the given key

func (*Map) Has

func (m *Map) Has(key string) bool

Has checks if the map contains the given key

func (*Map) Keys

func (m *Map) Keys() *Array

Keys returns all keys in the map as an array

func (*Map) Len

func (m *Map) Len() int

Len returns the number of entries in the map

func (*Map) Set

func (m *Map) Set(key string, value types.Object)

Set sets the value for the given key

func (*Map) ToStr

func (m *Map) ToStr() string

ToStr implements types.Object interface

func (*Map) TypeCode

func (m *Map) TypeCode() uint8

TypeCode implements types.Object interface

func (*Map) TypeName

func (m *Map) TypeName() string

TypeName implements types.Object interface

func (*Map) Values

func (m *Map) Values() *Array

Values returns all values in the map as an array

type OrderedMap

type OrderedMap struct {
	Entries map[string]types.Object
	Order   []string
}

OrderedMap represents an ordered key-value map that preserves insertion order

func NewOrderedMap

func NewOrderedMap() *OrderedMap

NewOrderedMap creates a new empty ordered map

func (*OrderedMap) Clear

func (om *OrderedMap) Clear()

Clear removes all entries from the map

func (*OrderedMap) Delete

func (om *OrderedMap) Delete(key string) types.Object

Delete removes the key from the map

func (*OrderedMap) Equals

func (om *OrderedMap) Equals(other types.Object) bool

Equals implements types.Object interface

func (*OrderedMap) Get

func (om *OrderedMap) Get(key string) types.Object

Get returns the value for the given key

func (*OrderedMap) Has

func (om *OrderedMap) Has(key string) bool

Has checks if the map contains the given key

func (*OrderedMap) Keys

func (om *OrderedMap) Keys() *Array

Keys returns all keys in insertion order as an array

func (*OrderedMap) Len

func (om *OrderedMap) Len() int

Len returns the number of entries in the map

func (*OrderedMap) MoveTo

func (om *OrderedMap) MoveTo(key string, index int) bool

MoveTo moves the given key to the specified 0-based index Returns true if the key exists and index is valid, false otherwise

func (*OrderedMap) MoveToFirst

func (om *OrderedMap) MoveToFirst(key string) bool

MoveToFirst moves the given key to the first position

func (*OrderedMap) MoveToLast

func (om *OrderedMap) MoveToLast(key string) bool

MoveToLast moves the given key to the last position

func (*OrderedMap) Set

func (om *OrderedMap) Set(key string, value types.Object)

Set sets the value for the given key

func (*OrderedMap) Sort

func (om *OrderedMap) Sort(comparator func(a, b string) bool)

Sort sorts the map keys using the given comparator

func (*OrderedMap) ToStr

func (om *OrderedMap) ToStr() string

ToStr implements types.Object interface

func (*OrderedMap) TypeCode

func (om *OrderedMap) TypeCode() uint8

TypeCode implements types.Object interface

func (*OrderedMap) TypeName

func (om *OrderedMap) TypeName() string

TypeName implements types.Object interface

func (*OrderedMap) Values

func (om *OrderedMap) Values() *Array

Values returns all values in insertion order as an array

type Queue

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

Queue represents a FIFO (first-in first-out) data structure

func NewQueue

func NewQueue() *Queue

NewQueue creates a new empty queue

func (*Queue) Clear

func (q *Queue) Clear()

Clear removes all elements from the queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() types.Object

Dequeue removes and returns the first element from the queue

func (*Queue) Enqueue

func (q *Queue) Enqueue(value types.Object)

Enqueue adds an element to the end of the queue

func (*Queue) Equals

func (q *Queue) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty

func (*Queue) Len

func (q *Queue) Len() int

Len returns the number of elements in the queue

func (*Queue) Peek

func (q *Queue) Peek() types.Object

Peek returns the first element without removing it

func (*Queue) ToStr

func (q *Queue) ToStr() string

ToStr implements types.Object interface

func (*Queue) TypeCode

func (q *Queue) TypeCode() uint8

TypeCode implements types.Object interface

func (*Queue) TypeName

func (q *Queue) TypeName() string

TypeName implements types.Object interface

type RangeIterator added in v1.1.0

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

func NewRangeIterator added in v1.1.0

func NewRangeIterator(start, end, step int) *RangeIterator

func (*RangeIterator) Equals added in v1.1.0

func (ri *RangeIterator) Equals(other types.Object) bool

func (*RangeIterator) HasNext added in v1.1.0

func (ri *RangeIterator) HasNext() bool

func (*RangeIterator) Next added in v1.1.0

func (ri *RangeIterator) Next() types.Object

func (*RangeIterator) ToStr added in v1.1.0

func (ri *RangeIterator) ToStr() string

func (*RangeIterator) TypeCode added in v1.1.0

func (ri *RangeIterator) TypeCode() uint8

func (*RangeIterator) TypeName added in v1.1.0

func (ri *RangeIterator) TypeName() string

type Seq

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

Seq represents a self-growing sequence (auto-incrementing array) It automatically grows when accessing indices beyond its current length

func NewSeq

func NewSeq() *Seq

NewSeq creates a new empty sequence

func NewSeqWithCapacity

func NewSeqWithCapacity(capacity int) *Seq

NewSeqWithCapacity creates a new sequence with initial capacity

func NewSeqWithElements

func NewSeqWithElements(elements []types.Object) *Seq

NewSeqWithElements creates a new sequence with the given elements

func (*Seq) Append

func (s *Seq) Append(value types.Object) *Seq

Append adds an element to the end of the sequence

func (*Seq) AppendMany

func (s *Seq) AppendMany(values ...types.Object) *Seq

AppendMany adds multiple elements to the end of the sequence

func (*Seq) Clear

func (s *Seq) Clear()

Clear removes all elements from the sequence

func (*Seq) Elements

func (s *Seq) Elements() []types.Object

Elements returns the underlying elements slice (for direct access)

func (*Seq) Equals

func (s *Seq) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Seq) Fill

func (s *Seq) Fill(value types.Object, count int) *Seq

Fill fills the sequence with a given value

func (*Seq) Filter

func (s *Seq) Filter(fn func(types.Object, int) bool) *Seq

Filter returns a new sequence with elements that pass the test

func (*Seq) Find

func (s *Seq) Find(fn func(types.Object, int) bool) types.Object

Find returns the first element that passes the test

func (*Seq) FindIndex

func (s *Seq) FindIndex(fn func(types.Object, int) bool) int

FindIndex returns the index of the first element that passes the test

func (*Seq) ForEach

func (s *Seq) ForEach(fn func(types.Object, int))

ForEach calls the given function for each element

func (*Seq) Get

func (s *Seq) Get(index int) types.Object

Get returns the element at the given index If index is beyond current length, returns undefined (auto-growth on read returns undefined)

func (*Seq) GetAuto

func (s *Seq) GetAuto(index int) types.Object

GetAuto returns the element at the given index, auto-growing if needed

func (*Seq) Includes

func (s *Seq) Includes(value types.Object) bool

Includes checks if the sequence contains a value

func (*Seq) IndexOf

func (s *Seq) IndexOf(value types.Object) int

IndexOf returns the first index of a value

func (*Seq) Join

func (s *Seq) Join(sep string) string

Join joins all elements with a separator

func (*Seq) Len

func (s *Seq) Len() int

Len returns the number of elements in the sequence

func (*Seq) Map

func (s *Seq) Map(fn func(types.Object, int) types.Object) *Seq

Map returns a new sequence with the results of applying the function to each element

func (*Seq) Pop

func (s *Seq) Pop() types.Object

Pop removes and returns the last element

func (*Seq) Range

func (s *Seq) Range(start, end int) *Seq

Range returns a new sequence with elements from start to end (exclusive)

func (*Seq) Resize

func (s *Seq) Resize(newSize int)

Resize changes the size of the sequence If new size is larger, new elements are initialized to undefined If new size is smaller, elements are removed from the end

func (*Seq) Reverse

func (s *Seq) Reverse() *Seq

Reverse reverses the sequence in place

func (*Seq) Set

func (s *Seq) Set(index int, value types.Object) types.Object

Set sets the element at the given index Auto-grows the sequence if index is beyond current length

func (*Seq) ToStr

func (s *Seq) ToStr() string

ToStr implements types.Object interface

func (*Seq) TypeCode

func (s *Seq) TypeCode() uint8

TypeCode implements types.Object interface

func (*Seq) TypeName

func (s *Seq) TypeName() string

TypeName implements types.Object interface

type Stack

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

Stack represents a LIFO (last-in first-out) data structure

func NewStack

func NewStack() *Stack

NewStack creates a new empty stack

func (*Stack) Clear

func (s *Stack) Clear()

Clear removes all elements from the stack

func (*Stack) Equals

func (s *Stack) Equals(other types.Object) bool

Equals implements types.Object interface

func (*Stack) IsEmpty

func (s *Stack) IsEmpty() bool

IsEmpty returns true if the stack is empty

func (*Stack) Len

func (s *Stack) Len() int

Len returns the number of elements in the stack

func (*Stack) Peek

func (s *Stack) Peek() types.Object

Peek returns the top element without removing it

func (*Stack) Pop

func (s *Stack) Pop() types.Object

Pop removes and returns the top element from the stack

func (*Stack) Push

func (s *Stack) Push(value types.Object)

Push adds an element to the top of the stack

func (*Stack) ToStr

func (s *Stack) ToStr() string

ToStr implements types.Object interface

func (*Stack) TypeCode

func (s *Stack) TypeCode() uint8

TypeCode implements types.Object interface

func (*Stack) TypeName

func (s *Stack) TypeName() string

TypeName implements types.Object interface

Jump to

Keyboard shortcuts

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