ジャンプ先: 概要. 戻り値. MEL 例.

概要

int floatArrayInsertAtIndex(int $index, float[] $list, float $item)

float 配列 $list の $index に $item を挿入します。$index が $list の最後のインデックスよりも大きい場合、$item はリストの末尾に配置されます。

戻り値

int :$index が負の場合は false、成功した場合は true を返します。

引数

変数名 変数タイプ 説明
$indexint$list で $str を追加するインデックスです。
$listfloat[]float 値のリストです。
$itemfloat$index で $list に追加する新しい項目です。

MEL 例

  // Initialize the list

  float $list[] = {1.1, 3.3};
  // Result: 1.1 3.3 //

  // Insert in the middle of the sequence

  floatArrayInsertAtIndex(1, $list, 2.2 );
  // Result: 1 //

  print $list;
  // Result: 1.1 2.2 3.3 //

  // Insert before the first element

  floatArrayInsertAtIndex(-1, $list, 4.4 );
  // Result: 0 //

  // Insert at ( or after ) the last element

  floatArrayInsertAtIndex(10, $list, 4.4 );
  // Result: 1 //

  print $list;
  // Result: 1.1 2.2 3.3 4.4 //

  // Insert at the beginning of the sequence

  floatArrayInsertAtIndex( 0, $list, 0.0 );
  // Result: 1 //

  print $list;
  // Result: 0 1.1 2.2 3.3 4.4 //