Range of a SWIFT Array

Asked

Viewed 60 times

0

I have an array of bytes and I need to find out in which track (startindex and endindex) a byte this or if only has startindex

ex:

var Faixa1:Array<UInt16> = [2,4,6,8,10,11,12]
var Faixa2:Array<UInt16> = [1,2]

var Valor1:UInt16 = 2
var Valor2:UInt16 = 3

//valor1 na faixa1
//startindex: 2
//endindex: 2

//valor1 na faixa2
//startindex: 2
//endindex: 2

//valor2 na faixa1
//startindex: 2
//endindex: 4
  • The question seems a bit confusing. Is the array bytes or integers? Is the array always ordered? Do you search the indexes in the array or the value immediately before and after the searched value? If possible also enter the code you developed to solve the problem, even if it is not working.

  • is an array of bytes ordered, I have the block of code in Java, I am passing this implementation pro Swift, nothing I designed came to work, so I have nothing

  • @H.Cardoso can put the code in Java helps a lot

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.