Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.22
more ▼

asked Jun 18 '19 at 12:53 AM in C++ Programming

avatar image

1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Jun 18 '19 at 04:04 AM

avatar image

31 3 3

avatar image glimp7 Jun 18 '19 at 04:23 AM

Yeah, that's too bad. TDoubleLinkedList is just that with little added functionality. Anybody with less than a half-year of Comp Sci could write that.

avatar image henryLiu Jun 18 '19 at 04:52 AM

Actually TArray is designed to be fast, memory efficient and safe. TDoubleLinkedList is considered to build links between pointers. I would like to suggest using TArray as a container of data/memory, and using TDoubleLinkedList to build relationship of each data if need.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question