[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeDoubleArray
Class: McGeDoubleArray
2d.McGeDoubleArray
Double precision floating-point array
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new McGeDoubleArray(imp?, isDestroyImp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | object | Internal implementation object |
isDestroyImp? | boolean | - |
Example
ts
import { McGeDoubleArray } from "mxcad"
const array = new McGeDoubleArray();Properties
imp
• imp: any
Internal implementation object
Methods
append
▸ append(val): void
Add a value
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | Double precision floating-point number |
Returns
void
Example
ts
import { McGeDoubleArray } from "mxcad"
//Create an array instance
const array = new McGeDoubleArray();
array.append(3.14159);at
▸ at(index): number
Retrieve the values of data elements through array indexing
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | array index |
Returns
number
Example
ts
import { McGeDoubleArray } from "mxcad"
const array = new McGeDoubleArray();
//Get the value of a specific index location
const value = array.at(2); //Assuming that the position with index 2 has a valueclear
▸ clear(): void
Clear the array
Returns
void
Example
ts
//Array represents a McGeDoubleArray array
array.clear();copy
▸ copy(val): McGeDoubleArray
Copy the value of the object
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [McGeDoubleArray] (2d. McGeDoubleArray. md) | Double precision floating-point array |
Returns
Example
ts
import { McGeDoubleArray } from "mxcad"
//Array1 represents a double precision floating-point array
const array2 = new McGeDoubleArray();
array2.copy(array1);
//Now array2 and array1 have the same valueforEach
▸ forEach(call): void
iterate through an array
Parameters
| Name | Type | Description |
|---|---|---|
| Call | (val: number, index: number)=>void | callback function |
Returns
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}`);
})length
▸ length(): number
Return the length of the array
Returns
number
array length
Example
ts
import { McGeDoubleArray } from "mxcad"
const array = new McGeDoubleArray();
const length = array.length();//0setAt
▸ setAt(index, val): void
Set the value of data elements through array indexing
Parameters
| Name | Type | Description |
|---|---|---|
index | number | - |
| Val | number | Double precision floating-point number |
Returns
void
Example
ts
import { McGeDoubleArray } from "mxcad"
const array = new McGeDoubleArray();
array.setAt(1, 3.14159); //Set the value of the position with index 1 to 3.14159