Question about IntArrayList

Monkey Forums/Monkey Programming/Question about IntArrayList

ondesic(Posted 2013) [#1]
I am trying to load a int[] into an IntArrayList. Is there a way to do this? I tried .FillIntArray([34,23,45]), but it doesn't work. I want to be able to add something like this "[23,34,67]" to the IntArrayList. How would I easily do this?


MikeHart(Posted 2013) [#2]
IntArrayList??? It isn't a Monkey native object, right? Are you using a 3rd party module and if yes, from which one is it?


ondesic(Posted 2013) [#3]
Diddy's IntArrayList


MikeHart(Posted 2013) [#4]
Maybe you should tag the topic title accordingly. Like "Diddy: Question about IntArrayList".


Samah(Posted 2013) [#5]
I'm in the process of reworking ArrayList slightly such that you can just use ArrayList<Int> and it won't use any boxing. This should be a lot faster and will let you do the kind of thing you want. Currently working on some other projects though.


therevills(Posted 2013) [#6]
I am trying to load a int[] into an IntArrayList. Is there a way to do this?


Yep, just loop thru the array and add them to the IntArrayList:

Strict
Import diddy

Function Main:Int()
	Local intArray:Int[] = [30,22,44,55]
	Local intArrayList:IntArrayList = New IntArrayList
	
	For Local i:Int = 0 Until intArray.Length
		Print intArray[i]
		intArrayList.Add(intArray[i])
	Next
	Print "---------"
	For Local i:Int = Eachin intArrayList
		Print i
	Next
	
	Return 1
End