Re: Stack-based @nogc dynamic array

2019-05-17 Thread Kagamin via Digitalmars-d-learn
On Friday, 17 May 2019 at 06:58:54 UTC, Marco de Wild wrote: Thank you. I've looked into it, and it appears to be quite a big library. I've looked into mach.collect and mach.range, but I didn't manage to find what I was looking for (a simple array data structure). Do you recommend to look into

Re: Stack-based @nogc dynamic array

2019-05-17 Thread Mike Franklin via Digitalmars-d-learn
On Thursday, 16 May 2019 at 12:16:26 UTC, Marco de Wild wrote: Or are there any tips to roll my own implementation? I took a stab at it: --- @nogc: nothrow: pure: struct NoGcArray(size_t maxSize, T) { private T[maxSize] _buffer; private T[] _slice; private size_t _frontIndex;

Re: Stack-based @nogc dynamic array

2019-05-17 Thread Marco de Wild via Digitalmars-d-learn
Thank you both for the quick replies. On Thursday, 16 May 2019 at 12:55:34 UTC, Kagamin wrote: Try mach.d https://github.com/pineapplemachine/mach.d it uses explicit range accessors for iteration. Thank you. I've looked into it, and it appears to be quite a big library. I've looked into mach.

Re: Stack-based @nogc dynamic array

2019-05-17 Thread Marco de Wild via Digitalmars-d-learn
On Thursday, 16 May 2019 at 12:45:03 UTC, Adam D. Ruppe wrote: I think you have overcomplicated something quite simple. int[4] buffer; int bufferLength; buffer[bufferLength++] = item_to_append; buffer[bufferLength++] = item_to_append; int[] slice = buffer[0 .. bufferLength]; // you can use sl

Re: Stack-based @nogc dynamic array

2019-05-16 Thread Kagamin via Digitalmars-d-learn
Try mach.d https://github.com/pineapplemachine/mach.d it uses explicit range accessors for iteration.

Re: Stack-based @nogc dynamic array

2019-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
I think you have overcomplicated something quite simple. int[4] buffer; int bufferLength; buffer[bufferLength++] = item_to_append; buffer[bufferLength++] = item_to_append; int[] slice = buffer[0 .. bufferLength]; // you can use slice to any std.algorithm calls etc // just remember it is on the

Stack-based @nogc dynamic array

2019-05-16 Thread Marco de Wild via Digitalmars-d-learn
Hey all, I want to create a small collection of items to store intermediate results of a calculation. It runs on a background thread, so it does not need to be the most efficient implementation. However, I want to prevent my background thread introducing a stop-the-world garbage collection. I