You shouldcan use Sow
for this in conjunction with CheckAbort
:
Reap@CheckAbort[Sow[...], ...]
You can read more about this here
Other than that there is bags. It will be as fast as Sow
since Sow
is implemented in terms of bags, but you will not lose the content of the bag if you interrupt the computation.
Quick recap:
bag = Internal`Bag[{}] (* Create an empty bag *)
Internal`StuffBag[bag, value] (* Add a value to the bag *)
Internal`BagLength[bag] (* The number of values in the bag *)
Internal`BagPart[bag, part] (* Retrieve values from bag *)
Another option is to use linked lists.