A contiguous, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves. More...
#include <Index.h>
Public Member Functions | |
IndexOf (const std::shared_ptr< T > &ptr, int64_t offset, int64_t length, kernel::lib ptr_lib) | |
Creates an IndexOf from a full set of parameters. | |
IndexOf (int64_t length, kernel::lib ptr_lib=kernel::lib::cpu) | |
Allocates a new integer array buffer with a given length. | |
bool | is_empty_advanced () const |
Returns true if this is an empty 'advanced' index. | |
const std::shared_ptr< T > | ptr () const |
Reference-counted pointer to the integer array buffer. | |
kernel::lib | ptr_lib () const |
The Kernel Library that ptr uses. | |
T * | data () const |
Raw pointer to the beginning of data (i.e. offset accounted for). | |
int64_t | offset () const |
Location of item zero in the buffer, relative to ptr, measured in the number of elements. | |
int64_t | length () const |
Number of elements in the array. | |
const std::string | classname () const |
User-friendly name of this class: "Index8" , "IndexU8" , "Index32" , "IndexU32" , or "Index64" . | |
const std::string | tostring () const |
Returns a string representation of this array (single-line XML). | |
const std::string | tostring_part (const std::string &indent, const std::string &pre, const std::string &post) const |
Internal function to build an output string for tostring. | |
Form | form () const |
Returns the enum describing this Index's integer specialization. | |
T | getitem_at (int64_t at) const |
Returns the element at a given position in the array, handling negative indexing and bounds-checking like Python. | |
T | getitem_at_nowrap (int64_t at) const |
Returns the element at a given position in the array, without handling negative indexing or bounds-checking. | |
void | setitem_at_nowrap (int64_t at, T value) const |
Assigns an integer value (type T ) in-place. | |
IndexOf< T > | getitem_range (int64_t start, int64_t stop) const |
Subinterval of this array, handling negative indexing and bounds-checking like Python. | |
IndexOf< T > | getitem_range_nowrap (int64_t start, int64_t stop) const |
Subinterval of this array, without handling negative indexing or bounds-checking. | |
void | nbytes_part (std::map< size_t, int64_t > &largest) const |
Internal function used to calculate Content::nbytes. | |
const std::shared_ptr< Index > | shallow_copy () const override |
Copies this Index node without copying its buffer. | |
IndexOf< int64_t > | to64 () const override |
Converts this Index to an Index64 . | |
bool | iscontiguous () const override |
Returns true if this index is contiguous false otherwise. | |
const IndexOf< T > | deep_copy () const |
Copies this Index node and all the data in its buffer. | |
const IndexOf< T > | copy_to (kernel::lib ptr_lib) const |
bool | referentially_equal (const IndexOf< T > &other) const |
![]() | |
virtual | ~Index () |
Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. | |
virtual const std::shared_ptr< Index > | shallow_copy () const =0 |
Copies this Index node without copying its buffer. | |
virtual IndexOf< int64_t > | to64 () const =0 |
Converts this Index to an Index64 . | |
virtual bool | iscontiguous () const =0 |
Returns true if this index is contiguous false otherwise. | |
Static Public Member Functions | |
static IndexOf< T > | empty_advanced () |
Create a zero-length index representing an empty 'advanced' index. | |
![]() | |
static Form | str2form (const std::string &str) |
Converts a string into a Form enumeration. | |
static const std::string | form2str (Form form) |
Converts a Form enumeration into a string. | |
Additional Inherited Members | |
![]() | |
enum class | Form { i8 , u8 , i32 , u32 , i64 , kNumIndexForm } |
Integer type of an Index, used by ListForm, IndexedForm, etc. More... | |
A contiguous, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves.
The Index superclass abstracts over templated specializations:
IndexOf | ( | const std::shared_ptr< T > & | ptr, |
int64_t | offset, | ||
int64_t | length, | ||
kernel::lib | ptr_lib | ||
) |
Creates an IndexOf from a full set of parameters.
ptr | Reference-counted pointer to the integer array buffer. |
offset | Location of item zero in the buffer, relative to ptr , measured in the number of elements. We keep this information in two parameters (ptr and offset ) rather than moving ptr so that ptr can be reference counted among all arrays that use the same buffer. |
length | Number of elements in the array. |
Choose | the Kernel Library for this array, default:= kernel::lib::cpu |
IndexOf | ( | int64_t | length, |
kernel::lib | ptr_lib = kernel::lib::cpu |
||
) |
Allocates a new integer array buffer with a given length.
const std::string classname | ( | ) | const |
User-friendly name of this class: "Index8"
, "IndexU8"
, "Index32"
, "IndexU32"
, or "Index64"
.
const IndexOf< T > copy_to | ( | kernel::lib | ptr_lib | ) | const |
T * data | ( | ) | const |
Raw pointer to the beginning of data (i.e. offset accounted for).
const IndexOf< T > deep_copy | ( | ) | const |
Copies this Index node and all the data in its buffer.
See also shallow_copy.
|
static |
Create a zero-length index representing an empty 'advanced' index.
T getitem_at | ( | int64_t | at | ) | const |
Returns the element at a given position in the array, handling negative indexing and bounds-checking like Python.
The first item in the array is at 0
, the second at 1
, the last at -1
, the penultimate at -2
, etc.
T getitem_at_nowrap | ( | int64_t | at | ) | const |
Returns the element at a given position in the array, without handling negative indexing or bounds-checking.
IndexOf< T > getitem_range | ( | int64_t | start, |
int64_t | stop | ||
) | const |
Subinterval of this array, handling negative indexing and bounds-checking like Python.
The first item in the array is at 0
, the second at 1
, the last at -1
, the penultimate at -2
, etc.
Ranges beyond the array are not an error; they are trimmed to start = 0
on the left and stop = length() - 1
on the right.
This operation only affects the node metadata; its calculation time does not scale with the size of the array.
IndexOf< T > getitem_range_nowrap | ( | int64_t | start, |
int64_t | stop | ||
) | const |
Subinterval of this array, without handling negative indexing or bounds-checking.
If the array has Identities, the identity bounds are checked.
This operation only affects the node metadata; its calculation time does not scale with the size of the array.
bool is_empty_advanced | ( | ) | const |
Returns true if this is an empty 'advanced' index.
|
overridevirtual |
Returns true if this index is contiguous false otherwise.
Implements Index.
int64_t length | ( | ) | const |
Number of elements in the array.
void nbytes_part | ( | std::map< size_t, int64_t > & | largest | ) | const |
Internal function used to calculate Content::nbytes.
largest | The largest range of bytes used in each reference-counted pointer (size_t ). |
int64_t offset | ( | ) | const |
const std::shared_ptr< T > ptr | ( | ) | const |
Reference-counted pointer to the integer array buffer.
kernel::lib ptr_lib | ( | ) | const |
The Kernel Library that ptr uses.
bool referentially_equal | ( | const IndexOf< T > & | other | ) | const |
void setitem_at_nowrap | ( | int64_t | at, |
T | value | ||
) | const |
Assigns an integer value (type T
) in-place.
This modifies the array itself.
|
overridevirtual |
|
overridevirtual |
const std::string tostring | ( | ) | const |
Returns a string representation of this array (single-line XML).
const std::string tostring_part | ( | const std::string & | indent, |
const std::string & | pre, | ||
const std::string & | post | ||
) | const |
Internal function to build an output string for tostring.
indent | Indentation depth as a string of spaces. |
pre | Prefix string, usually an opening XML tag. |
post | Postfix string, usually a closing XML tag and carriage return. |