The Problem:
I have a semi-large [Int]
array, which contains ~ 25K to 60K elements. It was originally outputted into a text file by my first program and needs to be fed as a let
value into a second program. To do this, I manually copied it in. However, Swift just freezes whenever I try to initialize it. By freeze, I mean that it doesn't do anything, even after an hour.
Further investigation:
I confirmed that it was the size of the array causing the freeze-up, by creating a test program with just one line that just said let test = [the_array]
. That program is still running after an hour.
I have previously used arrays that contained 400-450K elements without any problems. However, those arrays didn't have to be initialized as a variable/constant, and each element only contained a number between 1-9. The array that is causing the freeze-up definitely has less than 100K elements, but each element contains an integer between 100-300K.
How am I able to initialize the array into the second program, and what exactly is causing the problem?
Other info: I'm using Swift 3.1.1 on Ubuntu 16.04 64bit, so I don't have access to Xcode. If you need the text file of the array, please leave a comment. File is uploaded here