Awkward Array: IndexOf< T > Class Template Reference

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
IndexOf< T > Class Template Reference

A contiguous, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves. More...

`#include <Index.h>`

Inheritance diagram for IndexOf< T >:

## 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
Public Member Functions inherited from Index
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 Public Member Functions inherited from 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
Public Types inherited from Index
enum class | Form { i8 , u8 , i32 , u32 , i64 , kNumIndexForm }
| Integer type of an Index, used by ListForm, IndexedForm, etc. More...

## Detailed Description

template<typename T>
class awkward::IndexOf< T >

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:

- `Index8`, which is `IndexOf<int8_t>`
- `IndexU8`, which is `IndexOf<uint8_t>`
- `Index32`, which is `IndexOf<int32_t>`
- `IndexU32`, which is `IndexOf<uint32_t>`
- `Index64`, which is `IndexOf<int64_t>`

## Constructor & Destructor Documentation

## ◆ IndexOf() [1/2]

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.

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() [2/2]

IndexOf | ( | int64_t | length,
|  | kernel::lib | ptr_lib = `kernel::lib::cpu`
| ) |  |

Allocates a new integer array buffer with a given length.

## Member Function Documentation

## ◆ classname()

const std::string classname | ( |  | ) | const

User-friendly name of this class: `"Index8"`, `"IndexU8"`, `"Index32"`, `"IndexU32"`, or `"Index64"`.

## ◆ copy_to()

const IndexOf< T > copy_to | ( | kernel::lib | ptr_lib | ) | const

## ◆ data()

T * data | ( |  | ) | const

Raw pointer to the beginning of data (i.e. offset accounted for).

## ◆ deep_copy()

const IndexOf< T > deep_copy | ( |  | ) | const

Copies this Index node and all the data in its buffer.

See also shallow_copy.

## ◆ empty_advanced()

static IndexOf< T > empty_advanced | ( |  | ) |
| static

Create a zero-length index representing an empty 'advanced' index.

## ◆ form()

Form form | ( |  | ) | const

Returns the enum describing this Index's integer specialization.

## ◆ getitem_at()

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.

## ◆ getitem_at_nowrap()

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.

## ◆ getitem_range()

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.

## ◆ getitem_range_nowrap()

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.

## ◆ is_empty_advanced()

bool is_empty_advanced | ( |  | ) | const

Returns true if this is an empty 'advanced' index.

## ◆ iscontiguous()

bool iscontiguous | ( |  | ) | const
| overridevirtual

Returns true if this index is contiguous false otherwise.

Implements Index.

## ◆ length()

int64_t length | ( |  | ) | const

Number of elements in the array.

## ◆ nbytes_part()

void nbytes_part | ( | std::map< size_t, int64_t > & | largest | ) | const

Internal function used to calculate Content::nbytes.

Parameters

  largest | The largest range of bytes used in each reference-counted pointer (`size_t`).

Note
  This method of accounting for overlapping buffers is insufficient: two nodes could use parts of the same buffer in which one doesn't completely overlap the other. It's not likely, but currently the calculation of Content::nbytes is an underestimate.

## ◆ offset()

int64_t offset | ( |  | ) | const

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.

## ◆ ptr()

const std::shared_ptr< T > ptr | ( |  | ) | const

Reference-counted pointer to the integer array buffer.

## ◆ ptr_lib()

kernel::lib ptr_lib | ( |  | ) | const

The Kernel Library that ptr uses.

## ◆ referentially_equal()

bool referentially_equal | ( | const IndexOf< T > & | other | ) | const

## ◆ setitem_at_nowrap()

void setitem_at_nowrap | ( | int64_t | at,
|  | T | value
| ) |  | const

Assigns an integer value (type `T`) in-place.

This modifies the array itself.

## ◆ shallow_copy()

const std::shared_ptr< Index > shallow_copy | ( |  | ) | const
| overridevirtual

Copies this Index node without copying its buffer.

See also deep_copy.

Implements Index.

## ◆ to64()

IndexOf< int64_t > to64 | ( |  | ) | const
| overridevirtual

Converts this Index to an `Index64`.

Implements Index.

## ◆ tostring()

const std::string tostring | ( |  | ) | const

Returns a string representation of this array (single-line XML).

## ◆ tostring_part()

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.

Parameters

  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.

The documentation for this class was generated from the following file:

- include/awkward/Index.h