Insert into collection (TArray), while preserving sort, just use std::list?
With C# and .Net, we have List. With C++ and stdlib, we have to std::list. With UE4, we have TArray.
I'd really like to just use std::list, but from what I've been reading, this is bad practice. And using a wrapper class could be very inefficient.
TArray::FindLastByPredicate could work, but does it expect the TArray to be sorted? I'm guessing it just iterates through the entire thing.
Let's say it does expect or can derive from itself that it's sorted. Does it return an index (lower/upper bound) even when there's not an exact match to the predicate?
This is how I use std::list::lower_bound/upper_bound or .Net's List.BinarySearch.
I'm guessing that TArray is just a dynamic array under the hood, whereas std::list and List are doubly-linked lists.
FindLastByPredicate just iterative searches an index of element which matches the predicate, otherwise return INDEX_NONE. TArray is a dynamically sized array, and suit for most of cases. TDoubleLinkedList is double-linked list in UE4.
answered Jun 18 '19 at 04:04 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here