Blueprint Basics (4) - Containers (Array, Map, Set)

Briefly describe
that containers are used to store data. The data can be user-defined types (objects) or predefined types. ue4 provides three different containers, namely Array, Map, and Set.
Array : Literally translated, it is an array, which is an ordered sequence of elements that can store multiple data of the same type. Arrays are stored contiguously in memory space and can be accessed by subscripting.

Map : It is a key-value pair container. The data in it is in pairs (Key, Value). Value is obtained by the Key value, and the Key value cannot be repeated.

Set : An associative container containing sorted objects, which are simply collections of keys, which are values.

Array
Create Array

Create a new variable sVal of String type, click the icon behind Variable Type in the Details panel, select Array, and click Compile

Set the default value of sVal in the Default Value section below, click the "+", add 5 elements

Get Array elements by subscript and print the output

output result

Query an element, if there is, return the index value, if not, return -1, query the G value

output result

Traverse the Array and use ForEachLoop to traverse directly, returning the value and index of the element each time.

result output

Other nodes and function descriptions

node

describe

Add

Takes in an array and a variable. It inserts that variable at the end of the array and increases the size of the array accordingly

Clear

 

will clear all data in the connected array, reset the array, and delete all index values ​​in the array

Contains Item

Nodes allow searching an array to find a specific item. If the item is found, then the node will output True, otherwise it will output False

Filter Array

 The node takes an array of type Actor (or any of its children) and filters the array based on the input Class . The result is a new array containing only the items in the original array that match the type of the connected class.

Find Item

 The node takes an array and a variable, and then looks up the index number at which the value of that variable was first found in the array

Get

 The node takes in an array and an integer value, which is used as the index number. Then it returns the array value found at the index number.

Insert Item

The node takes in an array, a variable value, and an integer value ( index number ) . Then, it inserts the value of the variable into the array at the position specified by the index value.

Last Index

Node returns the index number of the last value in the array.

Length

 Returns the size of the array or the number of items in the array. If there are N objects in the array, then Length will return N , and valid index values ​​for the array are from 0 to N-1

Remove Index

 The node removes that item from the array by using the item's index number. All other index numbers will be automatically updated to fill the gap.

Remove Item

 will remove an item from the array by taking in a variable value

Resize

The node will take in an array and an integer value, the integer value is the new size of the array

Array Elem

 Allows you to set a specific index of an array to a specific value.

Map
creation of Map
is similar to Array, first create a variable mVal, select Map, select String type for key, and select Vector type for value
Set the default value of sVal in the Default Value section below, click the "+", add 5 elements

Traverse the Map, first get the array of Key, then traverse the array, get the Value through the key, and then print the output

result output
Other nodes and function descriptions

SetCreate
Set
Create a new variable sVal of type String, click the icon behind Variable Type in the Details panel, select Set, and click Compile

Set the default value of sVal in the Default Value section below, click the "+", add 5 elements

Traverse the Set, first convert the Set to an Array, then traverse the array, and print the output

result output

Other nodes and function descriptions

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325777708&siteId=291194637