LoginSignup
0
0

More than 3 years have passed since last update.

P5.js 日本語リファレンス(p5.TypedDict)

Last updated at Posted at 2020-05-24

このページでは「P5.js 日本語リファレンス」 の p5.TypedDict クラスを説明します。

p5.TypedDict

説明文

すべての p5.Dictionary タイプの基底クラス。具体的に型指定された Dictionary クラスは、このクラスを継承します。

構文

new p5.TypedDict()

メソッド

  • size

    辞書に現在保存されているキーと値のペアの数を返します。

  • hasKey()

    指定したキーがディクショナリに存在する場合はtrueを返し、それ以外の場合はfalseを返します。

  • get()

    指定されたキーに格納されている値を返します。

  • set()

    指定されたキーに関連付けられている値が辞書にすでに存在する場合はその値を更新します。それ以外の場合は、新しいキーと値のペアが追加されます。

  • create()

    辞書に新しいキーと値のペアを作成します。

  • clear()

    以前に保存されたすべてのキーと値のペアをディクショナリから削除します。

  • remove()

    指定されたキーに格納されているキーと値のペアをディクショナリから削除します。

  • print()

    辞書に現在保存されているアイテムのセットをコンソールに記録します。

  • saveTable()

    辞書をローカルダウンロード用のCSVファイルに変換します。

  • saveJSON()

    辞書をローカルダウンロード用のJSONファイルに変換します。

function setup() {

  // キー 100 に 1 を設定して、p5.NumberDict のオブジェクトを生成
  let myDict = createNumberDict(100, 1);
//  let myDict = createStringDict("100", "1");

  // キー 100 と値 1 はクリアする
  myDict.clear();
  myDict.set("101", 2);  // キー 101 に 2 を保存
  myDict.set("102", 4);  // キー 102 に 4 を保存

  myDict.print(); // すべてのキーと値を表示する
}

実行結果

著作権

p5.js was created by Lauren McCarthy and is developed by a community of collaborators, with support from the Processing Foundation and NYU ITP. Identity and graphic design by Jerel Johnson.

ライセンス

Creative Commons(CC BY-NC-SA 4.0) に従います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0