Class Reference intList

The intList class provides a list of integer numbers. More...

Member

intList( )
intList( intList list )
void append(int value)
int at(int pos)
void clear()
bool contains(int value)
void insert(int pos, int value)
int indexOf(int value, int index=0)
void prepend(int value)
int removeAll(int value)
void removeAt(int pos)
int size()
void set(int pos, int value)
void swap(int pos1, int pos2)

Detailed Description

graph LR f(file)--readBinary-->il(intList) su(setup)--getNetlistNotUseDatatype-->il click f "/layoutscript/api/file" click su "/layoutscript/api/setup" click il "/layoutscript/api/intlist" classDef thisClas fill:#eaf5fc,stroke:#3c7faa,stroke-width:4px; classDef clas fill:#eaf5fc,stroke:#3c7faa,stroke-width:1px; class il thisClas class f,su clas

A intList is a dynamic list of integers. file readBinary fills one int per byte; writeBinary writes that list back. setup getNetlistNotUseDatatype also returns one. In C++ macros this type is the same as an integer array, so you can use both a[i] and a.at(i). Index 0 is the first entry; size is the count; set does nothing if pos is past the end. append, insert, prepend, and removeAt change the length. contains and indexOf search. In Python this maps to a native list of integers.

Example:

intList list;
list.append(1);
list.append(32);
list.append(67);
if (list.contains(32)) {
 int v = list.at(1);
 list.set(0, v);
}

Member Function Documentation


intList::intList( )

Creates an empty list of integers.


intList::intList( intList list )

Creates a list of integers with copied data from list.


void intList::append(int value)

Inserts value at the end of the list.


int intList::at(int pos)

Returns: the integer at index pos. The first entry is 0.


void intList::clear()

Removes all items from the list. (introduced with release 20230121)


bool intList::contains(int value)

Returns: true if the list contains value, otherwise false.


void intList::insert(int pos, int value)

Inserts value at pos. Later entries move one position.


int intList::indexOf(int value, int index=0)

Returns: the index of the first occurrence of value, searching forward from index. Returns -1 if value is not found.


void intList::prepend(int value)

Inserts value at the beginning of the list. (introduced with release 20260714)


int intList::removeAll(int value)

Removes every occurrence of value.

Returns: the number of entries removed.


void intList::removeAt(int pos)

Removes the entry at pos. The list shrinks by one.


int intList::size()

Returns: the number of integers in the list.


void intList::set(int pos, int value)

Sets entry pos to value. The first entry is 0. Has no effect if the list is shorter than pos.


void intList::swap(int pos1, int pos2)

Swaps the values at pos1 and pos2.