index 類別

定義 N 維度索引向量。

語法

template <int _Rank>
class index;

參數

_排名
維度的排名或數目。

成員

公用建構函式

名稱 描述
index 建構函式 初始化 index 類別的新執行個體。

公用運算子

名稱 描述
運算元-- 遞減 物件的每個專案 index
operator%= 當該元素除以數位時,計算 物件中 index 每個專案的模數(餘數)。
operator*= 將 物件的每個專案 index 乘以數位。
operator/= 將 物件的每個專案 index 除以數位。
index::operator[] 傳回位於指定索引處的專案。
operator++ 遞增 物件的每個專案 index
operator+= 將指定的數位加入至 物件的每個專案 index
operator= 將指定 index 之物件的內容複寫到這個物件中。
operator-= 從 物件的每個元素 index 減去指定的數位。

公用常數

名稱 描述
rank 常數 儲存物件的排名 index

繼承階層架構

index

備註

結構 index 代表 N 整數的 座標向量,指定 N 維度空間中 的唯一位置。 向量中的值會從最顯著到最不重要的順序排序。 您可以使用 operator= 來擷取元件 的值。

需求

標頭︰ amp.h

命名空間: 並行

index 建構函式

初始化索引類別的新實例。

index() restrict(amp,cpu);

index(
   const index<_Rank>& _Other
) restrict(amp,cpu);

explicit index(
   int _I
) restrict(amp,cpu);

index(
   int _I0,
   int _I1
) restrict(amp,cpu);

index(
   int _I0,
   int _I1,
   int _I2
) restrict(amp,cpu);

explicit index(
   const int _Array[_Rank]
) restrict(amp,cpu);

參數

_陣 列
具有排名值的一維陣列。

_I
一維索引中的索引位置。

_I0
最顯著維度的長度。

_I1
下一個最大維度的長度。

_I2
最小有效維度的長度。

_其他
新索引物件所依據的索引物件。

運算元--

遞減索引物件的每個專案。

index<_Rank>& operator--() restrict(amp,cpu);

index operator--(
   int
) restrict(amp,cpu);

傳回值

針對前置詞運算子,索引物件 ( *this )。 如果是尾碼運算子,則為新的索引物件。

operator%=

當該元素除以指定的數位時,計算索引物件中每個專案的模數(餘數)。

index<_Rank>& operator%=(
   int _Rhs
) restrict(cpu, amp);

參數

_Rhs
要除以尋找模數的數位。

傳回值

索引物件。

operator*=

將索引物件中的每個專案乘以指定的數位。

index<_Rank>& operator*=(
   int _Rhs
) restrict(amp,cpu);

參數

_Rhs
要相乘的數位。

operator/=

將索引物件中的每個專案除以指定的數位。

index<_Rank>& operator/=(
   int _Rhs
) restrict(amp,cpu);

參數

_Rhs
要除以的數位。

operator[]

傳回位於指定位置之索引的元件。

int operator[] (
   unsigned _Index
) const restrict(amp,cpu);

int& operator[] (
   unsigned _Index
) restrict(amp,cpu);

參數

_指數
從 0 到排名減 1 的整數。

傳回值

位於指定索引處的專案。

備註

下列範例會顯示索引的元件值。

// Prints 1 2 3.
concurrency::index<3> idx(1, 2, 3);
std::cout << idx[0] << "\n";
std::cout << idx[1] << "\n";
std::cout << idx[2] << "\n";

operator++

遞增索引物件的每個專案。

index<_Rank>& operator++() restrict(amp,cpu);

index<_Rank> operator++(
   int
) restrict(amp,cpu);

傳回值

針對前置詞運算子,索引物件 ( *this )。 如果是尾碼運算子,則為新的索引物件。

operator+=

將指定的數位加入至索引物件的每個專案。

index<_Rank>& operator+=(
   const index<_Rank>& _Rhs
) restrict(amp,cpu);

index<_Rank>& operator+=(
   int _Rhs
) restrict(amp,cpu);

參數

_Rhs
要加入的數位。

傳回值

索引物件。

operator=

將指定之索引物件的內容複寫到這個物件中。

index<_Rank>& operator=(
   const index<_Rank>& _Other
) restrict(amp,cpu);

參數

_其他
要複製的來源索引物件。

傳回值

這個索引物件的參考。

operator-=

從索引物件的每個專案減去指定的數位。

index<_Rank>& operator-=(
   const index<_Rank>& _Rhs
) restrict(amp,cpu);

index<_Rank>& operator-=(
   int _Rhs
) restrict(amp,cpu);

參數

_Rhs
要減去的數位。

傳回值

索引物件。

順位

取得索引物件的排名。

static const int rank = _Rank;

另請參閱

Concurrency 命名空間 (C++ AMP)