[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeDoubleArray
Class: McGeDoubleArray
2d.McGeDoubleArray
McGeDoubleArray represents an array container of double precision floating-point numbers.
Description
This class is used to store and process floating-point sets, commonly used in numerical sampling, coordinate value caching Transform parameters and other scenarios that require continuous floating-point data.
Example
import { McGeDoubleArray } from "mxcad";
const values = new McGeDoubleArray();
values.append(1.2);
values.append(3.4);
values.append(5.6);
console.log(values.at(1)); //Obtain the value of the first index position;
console.log(values.length()); //Obtain the length of the 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 | - |
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
at
▸ at(index): number
Retrieve the values of data elements through array indexing
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | array index |
Returns
number
clear
▸ clear(): void
Clear the array
Returns
void
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
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
Traverse the array
Parameters
| Name | Type | Description |
|---|---|---|
| Call | (val: number, index: number)=>void | callback function |
Returns
void
Example
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
setAt
▸ 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
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