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"

TMap access elements by index

I'm using a map to count votes for a voting system, so the vote string is the key, and the vote count is the value.

I sort the map to get the top vote, but now how do I access the top vote? A hack way of doing it I came up with was doing a for loop and breaking on the first iteration.

But what if there's a tie? I need to check if the second element and first element have the same count?

I need to be able to access elements in ordered indices. Can I do that? Or is there something else that can help me?

Product Version: UE 4.8
more ▼

asked Aug 26 '15 at 07:52 AM in C++ Programming

avatar image

138 13 15 27

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

1 answer: sort voted first

Convert keys/values to an array and you will be able to access them with index. https://docs.unrealengine.com/latest/CHN/Programming/UnrealArchitecture/TMap/index.html

GenerateKeyArray and GenerateValueArray keywords.

more ▼

answered Aug 26 '15 at 11:22 AM

avatar image

2.6k 73 49 131

avatar image ScopeDogCustom Aug 07 '18 at 07:39 PM


 TMap<AActor*, float>ContactsMap;
 TArray<AActor*> ContactArray;
 AActor* CurrentContact = ContactArray[0];
(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