Skip to content

[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

ts
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

NameTypeDescription
imp?` ObjectInternal implementation object

Properties

imp

imp: any

Internal implementation object

Methods

append

append(val): void

Add a value to an array

Parameters

NameTypeDescription
Valnumberinteger value

Returns

void


at

at(index): number

Obtain the values of data elements based on the array index

Parameters

NameTypeDescription
Indexnumberarray 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

NameTypeDescription
Val[McGeLongArray] (2d. McGeLongArray. md)Integer array

Returns

McGeLongArray

Example

ts
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

NameTypeDescription
AryId[McObject Id] (2d. McObject Id. md) []McObject Id array

Returns

McGeLongArray


forEach

forEach(call): void

Traverse the array

Parameters

NameTypeDescription
Call(val: number, index: number)=>voidcallback function

Returns

void

Example

ts
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 10

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

NameTypeDescription
Indexnumberarray index value
Valnumberinteger numerical value

Returns

void