Mojo struct
DimList
This type represents a list of dimensions. Each dimension may have a static value or not have a value, which represents a dynamic dimension.
Fieldsβ
- βvalue (
VariadicList[Dim]
): The underlying storage for the list of dimensions.
Implemented traitsβ
AnyType
,
Formattable
,
Sized
,
Stringable
Methodsβ
__init__
β
__init__(inout self: Self, values: Tuple[Int])
Creates a dimension list from the given list of values.
Args:
- βvalues (
Tuple[Int]
): The initial dim values list.
__init__(inout self: Self, values: Tuple[Int, Int])
Creates a dimension list from the given list of values.
Args:
- βvalues (
Tuple[Int, Int]
): The initial dim values list.
__init__(inout self: Self, values: Tuple[Int, Int, Int])
Creates a dimension list from the given list of values.
Args:
- βvalues (
Tuple[Int, Int, Int]
): The initial dim values list.
__init__(inout self: Self, values: VariadicList[Dim])
Creates a dimension list from the given list of values.
Args:
- βvalues (
VariadicList[Dim]
): The initial dim values list.
__init__(inout self: Self, *values: Dim)
Creates a dimension list from the given Dim values.
Args:
- β*values (
Dim
): The initial dim values.
__len__
β
__len__(self: Self) -> Int
Gets the size of the DimList.
Returns:
The number of elements in the DimList.
get
β
get[i: Int](self: Self) -> Int
Gets the static dimension value at a specified index.
Parameters:
- βi (
Int
): The dimension index.
Returns:
The static dimension value at the specified index.
at
β
at[i: Int](self: Self) -> Dim
Gets the dimension at a specified index.
Parameters:
- βi (
Int
): The dimension index.
Returns:
The dimension at the specified index.
has_value
β
has_value[i: Int](self: Self) -> Bool
Returns True if the dimension at the given index has a static value.
Parameters:
- βi (
Int
): The dimension index.
Returns:
Whether the specified dimension has a static value.
product
β
product[length: Int](self: Self) -> Dim
Computes the product of the first length
dimensions in the list.
If any are dynamic, the result is a dynamic dimension value.
Parameters:
- βlength (
Int
): The number of elements in the list.
Returns:
The product of the first length
dimensions.
product[start: Int, end: Int](self: Self) -> Dim
Computes the product of a range of the dimensions in the list.
If any in the range are dynamic, the result is a dynamic dimension value.
Parameters:
- βstart (
Int
): The starting index. - βend (
Int
): The end index.
Returns:
The product of all the dimensions.
product(self: Self) -> Dim
Computes the product of all the dimensions in the list.
If any are dynamic, the result is a dynamic dimension value.
Returns:
The product of all the dimensions.
contains
β
contains[length: Int](self: Self, value: Dim) -> Bool
Determines whether the dimension list contains a specified dimension value.
Parameters:
- βlength (
Int
): The number of elements in the list.
Args:
- βvalue (
Dim
): The value to find.
Returns:
True if the list contains a dimension of the specified value.
all_known
β
all_known[length: Int](self: Self) -> Bool
Determines whether all dimensions are statically known.
Parameters:
- βlength (
Int
): The number of elements in the list.
Returns:
True if all dimensions have a static value.
all_known[start: Int, end: Int](self: Self) -> Bool
Determines whether all dimensions within [start, end) are statically known.
Parameters:
- βstart (
Int
): The first queried dimension. - βend (
Int
): The last queried dimension.
Returns:
True if all queried dimensions have a static value.
create_unknown
β
static create_unknown[length: Int]() -> Self
Creates a dimension list of all dynamic dimension values.
Parameters:
- βlength (
Int
): The number of elements in the list.
Returns:
A list of all dynamic dimension values.
__str__
β
__str__(self: Self) -> String
Converts the DimList to a String. The String is a comma separated list of the string representation of Dim.
Returns:
The string representation of the type.
format_to
β
format_to(self: Self, inout writer: Formatter)
Formats this DimList to the provided formatter.
Args:
- βwriter (
Formatter
): The formatter to write to.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?