首页 > 文档 > IntDict整数型字典类
2017
07-17

IntDict整数型字典类

Name

IntDict整数型字典类

Examples

IntDict inventory;

 

void setup() {

size(200, 200);

inventory = new IntDict();

inventory.set(“cd”, 84);

inventory.set(“tapes”, 15);

inventory.set(“records”, 102);

println(inventory);

noLoop();

fill(0);

textAlign(CENTER);

}

 

void draw() {

int numRecords = inventory.get(“records”);

text(numRecords, width/2, height/2);

}


 

Description

A simple class to use a String as a lookup for an int value. String “keys” are associated with integer values.

使用字符串作为 int 值的查找的简单类。字符串与整数值相关联。

Methods

size()

Returns the number of key/value pairs

返回键/值对的个数

clear()

Remove all entries清空

keyArray()

Return a copy of the internal keys array返回内部键数组的副本

values()

Return the internal array being used to store the values返回用于存储值的内部数组

valueArray()

Create a new array and copy each of the values into it创建一个新数组并将每个值复制到其中

get()

Return a value for the specified key返回指定键的值

set()

Create a new key/value pair or change the value of one创建新的键/值对或更改一个值

hasKey()

Check if a key is a part of the data structure检查键是否为数据结构的一部分

increment()

Increase the value of a specific key value by 1

add()

Add to a value加

sub()

Subtract from a value减

mult()

Multiply a value乘

div()

Divide a value除

remove()

Remove a key/value pair删除键/值对

sortKeys()

Sort the keys alphabetically按字母顺序对键排序

sortKeysReverse()

Sort the keys alphabetically in reverse按字母顺序对键反向排序

sortValues()

Sort by values in ascending order按值按升序排列

sortValuesReverse()

Sort by values in descending order按值降序排列

   

Constructor

IntDict()

IntDict(pairs)

Related

FloatDict
StringDict



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。