| スクリプト (MEL) |
MEL でのみ使用可能 |
stringArrayInsertAtIndex |
カテゴリ内: 言語, Array |
ジャンプ先: 概要. 戻り値. MEL 例.
int stringArrayInsertAtIndex(int $index, string[] $list, string $item)
文字配列 $list の $index に $item を挿入します。$index が $list の最後のインデックスよりも大きい場合、$item はリストの末尾に配置されます。
| int :$index が負の場合は false、成功した場合は true を返します。 |
引数
| 変数名 |
変数タイプ |
説明 |
| $index | int | $list で $str を追加するインデックスです。
|
| $list | string[] | 文字列値のリストです。
|
| $item | string | $index で $list に追加する新しい項目です。
|
// Initialize the list
string $list[] = {"item1", "item3"};
// Result: item1 item3 //
// Insert in the middle of the sequence
stringArrayInsertAtIndex(1, $list, "item2");
// Result: 1 //
print $list;
// Result: item1 item2 item3 //
// Insert before the first element
stringArrayInsertAtIndex(-1, $list, "item4" );
// Result: 0 //
// Insert at (or after) the end of the sequence
stringArrayInsertAtIndex( 10, $list, "item4" );
// Result: 1 //
print $list;
// Result: item1 item2 item3 item4 //
// Insert at the beginning of the sequence
stringArrayInsertAtIndex( 0, $list, "item0" );
// Result: 1 //
print $list;
// Result: item0 item1 item2 item3 item4 //