Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func Append[T any](slice []T, item T) []T
- func AppendAll[T any](lhs []T, rhs ...T) []T
- func BackPad[T any](slice []T, n uint, item T) []T
- func BitwidthOfVectors[T any](vectors ...Vector[T]) []uint
- func Compare[T Comparable[T]](lhs []T, rhs []T) int
- func ContainsMatching[T any](items []T, predicate Predicate[T]) bool
- func CountMatching[T any](items []T, predicate Predicate[T]) uint
- func CountUnique[T cmp.Ordered](items []T) uint
- func Expand[T any](data []T, n uint) []T
- func Filter[T any](items []T, predicate Predicate[T]) (nitems []T)
- func FindMatching[T any](items []T, predicate Predicate[T]) uint
- func FlatMap[S, T any](items []S, fn func(S) []T) []T
- func Flatten[T any](items []T, fn func(T) []T) []T
- func FrontPad[T any](slice []T, n uint, item T) []T
- func InsertAllAt[T any](items []T, elements []T, index uint) []T
- func InsertAt[T any](items []T, element T, index uint) []T
- func Map[S, T any](items []S, mapping func(uint, S) T) []T
- func MaxWidthOfVectors[T any](vectors ...Vector[T]) uint
- func MergeSorted[S Comparable[S]](lhs []S, rhs []S) []S
- func Prepend[T any](item T, slice []T) []T
- func RemoveAt[T any](items []T, index uint) []T
- func RemoveMatching[T any](items []T, predicate Predicate[T]) []T
- func RemoveMatchingIndexed[T any](items []T, predicate func(int, T) bool) []T
- func ReplaceFirstOrPanic[T comparable](columns []T, from T, to T)
- func Reverse[T any](items []T) []T
- func ReverseInPlace[T any](items []T)
- func ToString[S fmt.Stringer](arr []S) string
- func WidthOfVectors[T any](vectors ...Vector[T]) uint
- type Array
- type BitArray
- func (p *BitArray[T]) Append(word T) MutArray[T]
- func (p *BitArray[T]) BitWidth() uint
- func (p *BitArray[T]) Clone() MutArray[T]
- func (p *BitArray[T]) Get(index uint) T
- func (p *BitArray[T]) Len() uint
- func (p *BitArray[T]) Pad(n uint, m uint, padding T) MutArray[T]
- func (p *BitArray[T]) Set(index uint, word T) MutArray[T]
- func (p *BitArray[T]) SetRaw(index uint, val bool)
- func (p *BitArray[T]) Slice(start uint, end uint) Array[T]
- func (p *BitArray[T]) String() string
- type Builder
- type Comparable
- type ConstantArray
- func (p *ConstantArray[T]) Append(word T) MutArray[T]
- func (p *ConstantArray[T]) BitWidth() uint
- func (p *ConstantArray[T]) Build() Array[T]
- func (p *ConstantArray[T]) Clone() MutArray[T]
- func (p *ConstantArray[T]) Get(index uint) T
- func (p *ConstantArray[T]) Len() uint
- func (p *ConstantArray[T]) Pad(n uint, m uint, padding T) MutArray[T]
- func (p *ConstantArray[T]) Set(index uint, word T) MutArray[T]
- func (p *ConstantArray[T]) Slice(start uint, end uint) Array[T]
- func (p *ConstantArray[T]) String() string
- type DynamicBuilder
- type Encoding
- type MutArray
- type MutVector
- type Pool
- type PoolArray
- func (p *PoolArray[K, T, P]) Append(element T) MutArray[T]
- func (p *PoolArray[K, T, P]) BitWidth() uint
- func (p *PoolArray[K, T, P]) Clone() MutArray[T]
- func (p *PoolArray[K, T, P]) Get(index uint) T
- func (p *PoolArray[K, T, P]) Len() uint
- func (p *PoolArray[K, T, P]) Pad(n uint, m uint, padding T) MutArray[T]
- func (p *PoolArray[K, T, P]) Set(index uint, word T) MutArray[T]
- func (p *PoolArray[K, T, P]) Slice(start uint, end uint) Array[T]
- func (p *PoolArray[K, T, P]) String() string
- type Predicate
- type SmallArray
- func (p *SmallArray[K, T]) Append(word T) MutArray[T]
- func (p *SmallArray[K, T]) BitWidth() uint
- func (p *SmallArray[K, T]) Clone() MutArray[T]
- func (p *SmallArray[K, T]) Get(index uint) T
- func (p *SmallArray[K, T]) Len() uint
- func (p *SmallArray[K, T]) Pad(n uint, m uint, padding T) MutArray[T]
- func (p *SmallArray[K, T]) Set(index uint, word T) MutArray[T]
- func (p *SmallArray[K, T]) SetRaw(index uint, val K)
- func (p *SmallArray[K, T]) Slice(start uint, end uint) Array[T]
- func (p *SmallArray[K, T]) String() string
- type StaticArray
- func (p *StaticArray[T]) Append(word T) MutArray[T]
- func (p *StaticArray[T]) BitWidth() uint
- func (p *StaticArray[T]) Clone() MutArray[T]
- func (p *StaticArray[T]) Get(index uint) T
- func (p *StaticArray[T]) Len() uint
- func (p *StaticArray[T]) Pad(n uint, m uint, padding T) MutArray[T]
- func (p *StaticArray[T]) Set(index uint, word T) MutArray[T]
- func (p *StaticArray[T]) Slice(start uint, end uint) Array[T]
- func (p *StaticArray[T]) String() string
- type Vector
- func (p *Vector[T]) All(index uint, f Predicate[T]) bool
- func (p *Vector[T]) Clone() MutVector[T]
- func (p *Vector[T]) EmptyClone(length uint, builder Builder[T]) MutVector[T]
- func (p *Vector[T]) Len() uint
- func (p *Vector[T]) Limb(index uint) Array[T]
- func (p *Vector[T]) Read(index uint, values []T)
- func (p *Vector[T]) Some(index uint, f Predicate[T]) bool
- func (p *Vector[T]) Width() uint
Constants ¶
const ENCODING_POOL16_DENSE = 11
ENCODING_POOL16_DENSE is for arrays holding u16 indictes into a pool.
const ENCODING_POOL16_SPARSE16 = 18
ENCODING_POOL16_SPARSE16 is for arrays holding u16 indictes into a pool, and are stored in a sparse representation (assuming u16 block lengths).
const ENCODING_POOL16_SPARSE24 = 19
ENCODING_POOL16_SPARSE24 is currently not supported.
const ENCODING_POOL16_SPARSE32 = 20
ENCODING_POOL16_SPARSE32 is for arrays holding u16 indictes into a pool, and are stored in a sparse representation (assuming u32 block lengths).
const ENCODING_POOL16_SPARSE8 = 17
ENCODING_POOL16_SPARSE8 is for arrays holding u16 indictes into a pool, and are stored in a sparse representation (assuming u8 block lengths).
const ENCODING_POOL1_DENSE = 7
ENCODING_POOL1_DENSE is for arrays holding u1 indictes into a pool.
const ENCODING_POOL2_DENSE = 8
ENCODING_POOL2_DENSE is for arrays holding u2 indictes into a pool.
const ENCODING_POOL32_DENSE = 12
ENCODING_POOL32_DENSE is for arrays holding u32 indictes into a pool.
const ENCODING_POOL32_SPARSE16 = 22
ENCODING_POOL32_SPARSE16 is for arrays holding u32 indictes into a pool, and are stored in a sparse representation (assuming u16 block lengths).
const ENCODING_POOL32_SPARSE24 = 23
ENCODING_POOL32_SPARSE24 is currently not supported.
const ENCODING_POOL32_SPARSE32 = 24
ENCODING_POOL32_SPARSE32 is for arrays holding u32 indictes into a pool, and are stored in a sparse representation (assuming u32 block lengths).
const ENCODING_POOL32_SPARSE8 = 21
ENCODING_POOL32_SPARSE8 is for arrays holding u32 indictes into a pool, and are stored in a sparse representation (assuming u8 block lengths).
const ENCODING_POOL4_DENSE = 9
ENCODING_POOL4_DENSE is for arrays holding u4 indictes into a pool.
const ENCODING_POOL8_DENSE = 10
ENCODING_POOL8_DENSE is for arrays holding u8 indictes into a pool.
const ENCODING_POOL8_SPARSE16 = 14
ENCODING_POOL8_SPARSE16 is for arrays holding u8 indictes into a pool, and are stored in a sparse representation (assuming u16 block lengths).
const ENCODING_POOL8_SPARSE24 = 15
ENCODING_POOL8_SPARSE24 is currently not supported.
const ENCODING_POOL8_SPARSE32 = 16
ENCODING_POOL8_SPARSE32 is for arrays holding u8 indictes into a pool, and are stored in a sparse representation (assuming u8 block lengths).
const ENCODING_POOL8_SPARSE8 = 13
ENCODING_POOL8_SPARSE8 is for arrays holding u8 indictes into a pool, and are stored in a sparse representation (assuming u8 block lengths).
const ENCODING_POOL_CONSTANT = 6
ENCODING_POOL_CONSTANT is for arrays holding a constant index into a pool.
const ENCODING_STATIC_CONSTANT = 0
ENCODING_STATIC_CONSTANT is for arrays which hold constant values.
const ENCODING_STATIC_DENSE = 1
ENCODING_STATIC_DENSE is for arrays which hold their values explicitly.
const ENCODING_STATIC_SPARSE16 = 3
ENCODING_STATIC_SPARSE16 is for arrays which hold their values explicitly, and are stored in a sparse representation (assuming u16 block lengths).
const ENCODING_STATIC_SPARSE24 = 4
ENCODING_STATIC_SPARSE24 is currently not supported.
const ENCODING_STATIC_SPARSE32 = 5
ENCODING_STATIC_SPARSE32 is for arrays which hold their values explicitly, and are stored in a sparse representation (assuming u32 block lengths).
const ENCODING_STATIC_SPARSE8 = 2
ENCODING_STATIC_SPARSE8 is for arrays which hold their values explicitly, and are stored in a sparse representation (assuming u8 block lengths).
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append[T any](slice []T, item T) []T
Append creates a new slice containing the result of appending the given item onto the end of the given slice. Observe that, unlike the built-in append() function, this will never modify the given slice.
func AppendAll ¶
func AppendAll[T any](lhs []T, rhs ...T) []T
AppendAll creates a new slice containing the result of appending the given items onto the end of the given slice. Observe that, unlike the built-in append() function, this will never modify the given slice.
func BackPad ¶
BackPad pads an array upto a given length n with a given item. Specifically, new items are inserted at the end of the array.
func BitwidthOfVectors ¶
BitwidthOfVectors returns the maximum bitwidth of each limb across a given set of vectors.
func Compare ¶
func Compare[T Comparable[T]](lhs []T, rhs []T) int
Compare two slices of ordered elements.
func ContainsMatching ¶
ContainsMatching checks whether a given array contains an item matching a given predicate.
func CountMatching ¶
CountMatching counts the number of items in the given array for which the predicate returns true.
func CountUnique ¶
CountUnique counts the number of unique items within a given slice.
func Expand ¶
Expand ensures space for exactly n elements on top of this heap. This may result in allocation only if the underlying capacity is exhausted.
func FindMatching ¶
FindMatching determines the index of first matching item in a given array, or returns max.MaxUint otherwise.
func FlatMap ¶
func FlatMap[S, T any](items []S, fn func(S) []T) []T
FlatMap flattens items from an array which expand into arrays of terms.
func Flatten ¶
func Flatten[T any](items []T, fn func(T) []T) []T
Flatten flattens items from an array which expand into arrays of terms.
func FrontPad ¶
FrontPad pads an array upto a given length n with a given item. Specifically, new items are inserted at the front of the array.
func InsertAllAt ¶
InsertAllAt constructs an identical slice, except with the given elements inserted at the given index. If the index is beyond the bounds of the array, then the element is simply appended.
func InsertAt ¶
InsertAt constructs an identical slice, except with the element inserted at the given index. If the index is beyond the bounds of the array, then the element is simply appended.
func MaxWidthOfVectors ¶
MaxWidthOfVectors returns the maximum width of any vector in a given set of zero or more vectors.
func MergeSorted ¶
func MergeSorted[S Comparable[S]](lhs []S, rhs []S) []S
MergeSorted combines two sorted arrays whilst maintaining the sorted invariant. You can think of this as first appending the second array to the first, then sorting the result. In fact, it uses a merge sort which is slightly more efficient than resorting from scratch.
func Prepend ¶
func Prepend[T any](item T, slice []T) []T
Prepend creates a new slice containing the result of prepending the given item onto the end of the given slice. Observe that, unlike the built-in append() function, this will never modify the given slice.
func RemoveAt ¶
RemoveAt constructs an identical slice, except with the element at the given index removed. If the index is beyond the bounds of the array, then there is no change.
func RemoveMatching ¶
RemoveMatching removes all elements from an array matching the given item.
func RemoveMatchingIndexed ¶
RemoveMatchingIndexed removes all elements from an array matching the given item.
func ReplaceFirstOrPanic ¶
func ReplaceFirstOrPanic[T comparable](columns []T, from T, to T)
ReplaceFirstOrPanic replaces the first occurrence of a given item (from) in an array with another item (to). If not match is found, then this will panic. In otherwords, we are expecting a match.
func ReverseInPlace ¶
func ReverseInPlace[T any](items []T)
ReverseInPlace reversees the items in an array in place.
func ToString ¶
ToString constructs a string representation for an array of values which themselves have String() functions.
func WidthOfVectors ¶
WidthOfVectors returns the total number of limbs across all vectors.
Types ¶
type Array ¶
type Array[T any] interface { // Return the number of bits required to store an element of this array. BitWidth() uint // Clone this array producing a mutable copy Clone() MutArray[T] // Get returns the element at the given index in this array. Get(uint) T // Returns the number of elements in this array. Len() uint // Slice out a subregion of this array. Slice(uint, uint) Array[T] }
Array provides a generice interface to an array of elements. Typically, we are interested in arrays of field elements here.
type BitArray ¶
BitArray implements an array of single bit words simply using an underlying array of packed bytes. That is, where eight bits are packed into a single byte.
func NewBitArray ¶
NewBitArray constructs a new word array with a given capacity.
func (*BitArray[T]) Set ¶
Set sets the field element at the given index in this array, overwriting the original value.
func (*BitArray[T]) SetRaw ¶
SetRaw sets a raw bit at the given index in this array, overwriting the original value.
type Builder ¶
type Builder[T any] interface { // NewArray constructs a new array of the given height holding elements of the given bitwidth NewArray(height uint, bitwidth uint) MutArray[T] }
Builder is a mechanism for constructing arrays which aims to select the right representation for a given array.
func NewStaticBuilder ¶
NewStaticBuilder constructs a new array builder for dynamic words.
type Comparable ¶
type Comparable[T any] interface { // Cmp returns < 0 if this is less than other, or 0 if they are equal, or > // 0 if this is greater than other. Cmp(other T) int }
Comparable interface which can be implemented by non-primitive types.
type ConstantArray ¶
ConstantArray implements an array of a constant value.
func NewConstantArray ¶
func NewConstantArray[T word.Word[T]](height uint, bitwidth uint, value T) *ConstantArray[T]
NewConstantArray constructs a new word array with a given capacity.
func (*ConstantArray[T]) Append ¶
func (p *ConstantArray[T]) Append(word T) MutArray[T]
Append new word on this array
func (*ConstantArray[T]) BitWidth ¶
func (p *ConstantArray[T]) BitWidth() uint
BitWidth returns the width (in bits) of elements in this array.
func (*ConstantArray[T]) Build ¶
func (p *ConstantArray[T]) Build() Array[T]
Build implementation for the array.Builder interface. This simply means that a static array is its own builder.
func (*ConstantArray[T]) Clone ¶
func (p *ConstantArray[T]) Clone() MutArray[T]
Clone makes clones of this array producing an otherwise identical copy.
func (*ConstantArray[T]) Get ¶
func (p *ConstantArray[T]) Get(index uint) T
Get returns the field element at the given index in this array.
func (*ConstantArray[T]) Len ¶
func (p *ConstantArray[T]) Len() uint
Len returns the number of elements in this word array.
func (*ConstantArray[T]) Pad ¶
func (p *ConstantArray[T]) Pad(n uint, m uint, padding T) MutArray[T]
Pad implementation for MutArray interface.
func (*ConstantArray[T]) Set ¶
func (p *ConstantArray[T]) Set(index uint, word T) MutArray[T]
Set sets the field element at the given index in this array, overwriting the original value.
func (*ConstantArray[T]) Slice ¶
func (p *ConstantArray[T]) Slice(start uint, end uint) Array[T]
Slice out a subregion of this array.
func (*ConstantArray[T]) String ¶
func (p *ConstantArray[T]) String() string
type DynamicBuilder ¶
type DynamicBuilder[T word.DynamicWord[T], P pool.Pool[uint32, T]] struct { // contains filtered or unexported fields }
DynamicBuilder is for handling dynamic words only.
func NewDynamicBuilder ¶
func NewDynamicBuilder[T word.DynamicWord[T], P pool.Pool[uint32, T]](heap P) DynamicBuilder[T, P]
NewDynamicBuilder constructs a new array builder for dynamic words.
func (*DynamicBuilder[T, P]) Decode ¶
func (p *DynamicBuilder[T, P]) Decode(encoding Encoding) MutArray[T]
Decode reconstructs an array from an array encoding, given the pool as it was when the encoding was made.
func (*DynamicBuilder[T, P]) Encode ¶
func (p *DynamicBuilder[T, P]) Encode(array Array[T]) Encoding
Encode a given array as a sequence of bytes suitable for serialisation.
type Encoding ¶
type Encoding struct {
// Indicates what encoding method is used for this encoding.
Encoding uint32
// Bytes of the encoding itself
Bytes []byte
}
Encoding represents an encoded form of a word array useful for long term storage (e.g. in a file).
func Encode ¶
func Encode[T word.DynamicWord[T], P Pool[T]](array Array[T]) Encoding
Encode a given array as a sequence of bytes suitable for serialisation.
type MutArray ¶
type MutArray[T any] interface { Array[T] // Append new element onto the end of array producing an updated array. In // most cases, this updates the array in place and returns it. In some // cases, it may force a change of representation (e.g. moving from a // constant array). Append(T) MutArray[T] // Set the element at the given index in this array, overwriting the // original value. In most cases, this updates the array in place and // returns it. In some cases, it may force a change of representation (e.g. // moving from a constant array). Set(uint, T) MutArray[T] // Insert n copies of T at start of the array and m copies at the back. In // most cases, this updates the array in place and returns it. In some // cases, it may force a change of representation (e.g. moving from a // constant array). Pad(uint, uint, T) MutArray[T] }
MutArray provides a generice interface to an array of elements. Typically, we are interested in arrays of field elements here.
type MutVector ¶
type MutVector[T any] struct { // contains filtered or unexported fields }
MutVector represents a vector of mutable arrays. As such, this supports not only reading operations but also writing operations.
func MutVectorOf ¶
MutVectorOf constructs a mutable vector from a given set of mutable arrays. All supplied arrays are expected to have the same height, otherwise this will panic.
func NewMutVector ¶
NewMutVector creates a new mutable vector with a given number of limbs as determined by the given bitwidths.
type PoolArray ¶
type PoolArray[K uint8 | uint16 | uint32, T word.Word[T], P pool.Pool[K, T]] struct { // contains filtered or unexported fields }
PoolArray implements an array of elements simply using an underlying array.
func NewPoolArray ¶
func NewPoolArray[K uint8 | uint16 | uint32, T word.Word[T], P pool.Pool[K, T]](height uint, bitwidth uint, pool P) *PoolArray[K, T, P]
NewPoolArray constructs a new indexed array.
func (*PoolArray[K, T, P]) BitWidth ¶
BitWidth returns the width (in bits) of elements in this array.
func (*PoolArray[K, T, P]) Clone ¶
Clone makes clones of this array producing an otherwise identical copy.
func (*PoolArray[K, T, P]) Set ¶
Set sets the field element at the given index in this array, overwriting the original value.
type SmallArray ¶
type SmallArray[K uint8 | uint16 | uint32 | uint64, T word.Word[T]] struct { // contains filtered or unexported fields }
SmallArray implements an array of elements simply using an underlying array.
func NewSmallArray ¶
func NewSmallArray[K uint8 | uint16 | uint32 | uint64, T word.Word[T]](height uint, bitwidth uint) SmallArray[K, T]
NewSmallArray constructs a new word array with a given capacity.
func (*SmallArray[K, T]) Append ¶
func (p *SmallArray[K, T]) Append(word T) MutArray[T]
Append new word on this array
func (*SmallArray[K, T]) BitWidth ¶
func (p *SmallArray[K, T]) BitWidth() uint
BitWidth returns the width (in bits) of elements in this array.
func (*SmallArray[K, T]) Clone ¶
func (p *SmallArray[K, T]) Clone() MutArray[T]
Clone makes clones of this array producing an otherwise identical copy.
func (*SmallArray[K, T]) Get ¶
func (p *SmallArray[K, T]) Get(index uint) T
Get returns the word at the given index in this array.
func (*SmallArray[K, T]) Len ¶
func (p *SmallArray[K, T]) Len() uint
Len returns the number of elements in this word array.
func (*SmallArray[K, T]) Pad ¶
func (p *SmallArray[K, T]) Pad(n uint, m uint, padding T) MutArray[T]
Pad prepend array with n copies and append with m copies of the given padding value.
func (*SmallArray[K, T]) Set ¶
func (p *SmallArray[K, T]) Set(index uint, word T) MutArray[T]
Set the word at the given index in this array, overwriting the original value.
func (*SmallArray[K, T]) SetRaw ¶
func (p *SmallArray[K, T]) SetRaw(index uint, val K)
SetRaw sets a raw value at the given index in this array, overwriting the original value.
func (*SmallArray[K, T]) Slice ¶
func (p *SmallArray[K, T]) Slice(start uint, end uint) Array[T]
Slice out a subregion of this array.
func (*SmallArray[K, T]) String ¶
func (p *SmallArray[K, T]) String() string
type StaticArray ¶
StaticArray implements an array of elements simply using an underlying array.
func NewStaticArray ¶
func NewStaticArray[T word.Word[T]](height uint, bitwidth uint) *StaticArray[T]
NewStaticArray constructs a new word array with a given capacity.
func (*StaticArray[T]) Append ¶
func (p *StaticArray[T]) Append(word T) MutArray[T]
Append new word on this array
func (*StaticArray[T]) BitWidth ¶
func (p *StaticArray[T]) BitWidth() uint
BitWidth returns the width (in bits) of elements in this array.
func (*StaticArray[T]) Clone ¶
func (p *StaticArray[T]) Clone() MutArray[T]
Clone makes clones of this array producing an otherwise identical copy.
func (*StaticArray[T]) Get ¶
func (p *StaticArray[T]) Get(index uint) T
Get returns the field element at the given index in this array.
func (*StaticArray[T]) Len ¶
func (p *StaticArray[T]) Len() uint
Len returns the number of elements in this word array.
func (*StaticArray[T]) Pad ¶
func (p *StaticArray[T]) Pad(n uint, m uint, padding T) MutArray[T]
Pad prepend array with n copies and append with m copies of the given padding value.
func (*StaticArray[T]) Set ¶
func (p *StaticArray[T]) Set(index uint, word T) MutArray[T]
Set sets the field element at the given index in this array, overwriting the original value.
func (*StaticArray[T]) Slice ¶
func (p *StaticArray[T]) Slice(start uint, end uint) Array[T]
Slice out a subregion of this array.
func (*StaticArray[T]) String ¶
func (p *StaticArray[T]) String() string
type Vector ¶
type Vector[T any] struct { // contains filtered or unexported fields }
Vector represents a vector of identically sized arrays. This just makes it easier to work with such vectors, providing various bits of helpful functionality.
func VectorOf ¶
VectorOf constructs a new vector array from a given set of arrays. All supplied arrays are expected to have the same height, otherwise this will panic.
func (*Vector[T]) All ¶
All checks whether, for all limbs, the given predicate holds at a given index.
func (*Vector[T]) EmptyClone ¶
EmptyClone constructs a vector of mutable arrays of a given height which are all empty, but have matching dimension (i.e. same number of arrays with matching bitwidths).