[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeLongArray
Class: McGeLongArray
2d.McGeLongArray
McGeLongArray represents an array container for a set of integer values.
Description
This class is used to store and manipulate a set of integer data, commonly used for numerical caching within CAD Set of object IDs, color channel data, and other scenes. It provides common capabilities such as append, read, modify, and traverse.
Example
import { McGeLongArray } from "mxcad";
const values = new McGeLongArray();
values.append(10);
values.append(20);
values.append(30);
Console. log (values. length())//Get the length of the array;
Console. log (values. at (1))//Get the value of the element with index 1;Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new McGeLongArray(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | ` Object | Internal implementation object |
Properties
imp
• imp: any
Internal implementation object
Methods
append
▸ append(val): void
Add a value to an array
Parameters
| Name | Type | Description |
|---|---|---|
| Val | number | integer value |
Returns
void
at
▸ at(index): number
Obtain the values of data elements based on the array index
Parameters
| Name | Type | Description |
|---|---|---|
| Index | number | array index |
Returns
number
Return element value
clear
▸ clear(): void
Clear the array
Returns
void
copy
▸ copy(val): McGeLongArray
Copy the value of the object
Parameters
| Name | Type | Description |
|---|---|---|
| Val | [McGeLongArray] (2d. McGeLongArray. md) | Integer array |
Returns
Example
import { McGeLongArray } from "mxcad"
const array1 = new McGeLongArray();
const array2 = new McGeLongArray();
array2.append(10);
array2.append(20);
//Copy the value of array2 to array1
array1.copy(array2);copyFormAryId
▸ copyFormAryId(aryId): McGeLongArray
Copy values from the McObjectid array
Parameters
| Name | Type | Description |
|---|---|---|
| AryId | [McObject Id] (2d. McObject Id. md) [] | McObject Id array |
Returns
forEach
▸ forEach(call): void
Traverse the array
Parameters
| Name | Type | Description |
|---|---|---|
| Call | (val: number, index: number)=>void | callback function |
Returns
void
Example
import { McGeLongArray } from "mxcad"
const array = new McGeLongArray();
array.append(5);
array.append(10);
array.forEach((val, index) => {
console.log(`Index ${index}: Value ${val}`);
});
//Output:
// Index 0: Value 5
// Index 1: Value 10length
▸ 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 | array index value |
| Val | number | integer numerical value |
Returns
void
