#include#include int main() { TArray intArray = {1, 2, 3}; bool result = intArray.AddUnique(4); if (result) { std::cout << "Element was added" << std::endl; } else { std::cout << "Element was already present" << std::endl; } result = intArray.AddUnique(1); if (result) { std::cout << "Element was added" << std::endl; } else { std::cout << "Element was already present" << std::endl; } return 0; }
#includeIn this example, we create a string array and add the elements "hello" and "world". We then call AddUnique with the argument of "unreal", which is not already present in the array, so the function returns true and the element is added. We then call AddUnique again with the argument of "hello", which is already present in the array, so the function returns false and the element is not added. Package Library: Unreal Engine API.#include int main() { TArray stringArray = {"hello", "world"}; bool result = stringArray.AddUnique("unreal"); if (result) { std::cout << "Element was added" << std::endl; } else { std::cout << "Element was already present" << std::endl; } result = stringArray.AddUnique("hello"); if (result) { std::cout << "Element was added" << std::endl; } else { std::cout << "Element was already present" << std::endl; } return 0; }