I work with strings in pseudo C ++ scripts, Unrealscript, and faced with the fact that you need to identify duplicate rows in the array, that is, a string with the same content but under a different index, you need to somehow define it.

An array looks like this:

array<string> strArr; 

it already has lines in advance, something like this

 strArr = {"Temporarily","Increases","Momentarily", "Chance","Increases","Temporarily","Momentarily"};` 

If you iterate each word through a for loop

 for(i = 0; i < 100;i++) { debugf("string %s"strArr[i]); } 

How then to compare the read lines, on the duplicate - with those that go in the queue?

Create a duplicate array, and add another 1 loop inside the main one? Ie like this

 for(i=0;i<strArr.length;i++) { strArr[i]; for(k=0;k<strArrDub.length;k++) { if(strArr[i]==strArrDub[k]) } } 

And it turns out that if, for example, the main loop [i] stopped at the 7th element Momentarily , then the second cycle [k] will go through everything from 0 to the first occurrence of 'Momentarily', which will already be under index 3, and then the test will work, is not it ?

if yes then, is it possible to somehow present it differently or speed it up, there is a pseudo hashmap in Unrealscript, and some functions of the arrays do not work very well.

  • Do you need a specific order of rows in an array? Can they be rearranged? What to do with doubles? - Harry
  • @Harry, so far I want to understand how it will be more correct - to find these duplicates, and if a duplicate is found then you can simply add a counter to it, that is, + 1, + 2, + 3, how to determine them is more important, then I described in theory will work - but maybe there is something better? - LighFusion
  • @Harry would like to do something like an array iterator, Ar.begin ar.end, that is, so that you can add certain conditions - for example, in an array of 15 objects, I set the condition if (counter> 6 && counter <8) then we read objects from 0 to 6 (i.e. 7), and for example the object under index 3 is a duplicate of object under index 7, then I do the rubbing on the read lines - let them be 7, and add a rule - if the object is saved array == The object to be iterated, then the object to display. looks like this. pastebin.com/ixiLTEG3 , how best to present it? - LighFusion
  • Sorry that I was encouraged by my question, but I somehow did not notice that this is NOT a C ++ question ... And I can’t answer anything in the scripts. - Harry
  • one
    Well, in pure C ++, I would sort the lines, and then look at the neighboring ones - aren't they the same? If you need to remove duplicates, you would use the uniq algorithm. At least in your version of two cycles, I would use the same array - why the second one? - and the second cycle would start with k=i+1 . - Harry

0