Skip to content

mxcad_2d API 文档 / 2d / McGeDoubleArray

Class: McGeDoubleArray ​

2d.McGeDoubleArray

双精度浮点数数组

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new McGeDoubleArray(imp?, isDestroyImp?)

构造函数。

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();

Parameters ​

NameTypeDescription
imp?object内部实现对象
isDestroyImp?boolean-

Properties ​

imp ​

• imp: any

内部实现对象

Methods ​

append ​

▸ append(val): void

添加一个值

Example

ts
import { McGeDoubleArray } from "mxcad"

  // 创建数组实例
  const array = new McGeDoubleArray();
  array.append(3.14159);

Parameters ​

NameTypeDescription
valnumber双精度浮点数

Returns ​

void


at ​

▸ at(index): number

通过数组索引得到数据元素的值

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();
  // 获取特定索引位置的值 
  const value = array.at(2); // 假设索引为2的位置有值

Parameters ​

NameTypeDescription
indexnumber数组索引

Returns ​

number


clear ​

▸ clear(): void

清空数组

Example

ts
// array 表示一个McGeDoubleArray数组
  array.clear();

Returns ​

void


copy ​

▸ copy(val): McGeDoubleArray

复制对象的值

Example

ts
import { McGeDoubleArray } from "mxcad"

 // array1 表示一个双精度浮点数数组
 const array2 = new McGeDoubleArray();
 array2.copy(array1);

 // 现在array2与array1具有相同的值

Parameters ​

NameTypeDescription
valMcGeDoubleArray双精度浮点数数组

Returns ​

McGeDoubleArray


forEach ​

▸ forEach(call): void

遍历数组

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();
  array.append(3.14159);
  array.forEach((val,index)=>{
    console.log(`Value at index ${index}: ${value}`);
  })

Parameters ​

NameTypeDescription
call(val: number, index: number) => void回调函数

Returns ​

void


length ​

▸ length(): number

返回数组长度

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();
  const length = array.length();//0

Returns ​

number

数组长度


setAt ​

▸ setAt(index, val): void

通过数组索引设置数据元素的值

Example

ts
import { McGeDoubleArray } from "mxcad"

  const array = new McGeDoubleArray();
  array.setAt(1, 3.14159); // 将索引为1的位置的值设置为3.14159

Parameters ​

NameTypeDescription
indexnumber-
valnumber双精度浮点数

Returns ​

void