Re: Find in assoc array then iterate

2022-10-21 Thread Siarhei Siamashka via Digitalmars-d-learn
On Friday, 21 October 2022 at 22:03:53 UTC, Kevin Bailey wrote: I'm trying to do this equivalent C++: unordered_map map; for (auto i = map.find(something); i != map.end(); ++i) ...do something with i... in D, but obviously with an associative array. It seems that it's quite ea

Re: Find in assoc array then iterate

2022-10-21 Thread Kevin Bailey via Digitalmars-d-learn
Hi Sergey, While the unordered map doesn't guarantee an ordering (since its contents are hashed), the order should remain static if you don't insert or delete. Hi JG, Thanks for the red-black tree reference. I'll read up on it in case I need it but I'd prefer to use the built-in O(1) hash

Re: Find in assoc array then iterate

2022-10-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/21/22 6:03 PM, Kevin Bailey wrote: I'm trying to do this equivalent C++:     unordered_map map;     for (auto i = map.find(something); i != map.end(); ++i)     ...do something with i... in D, but obviously with an associative array. It seems that it's quite easy to iterate through

Re: Find in assoc array then iterate

2022-10-21 Thread Ali Çehreli via Digitalmars-d-learn
On 10/21/22 15:03, Kevin Bailey wrote: I'm trying to do this equivalent C++:     unordered_map map;     for (auto i = map.find(something); i != map.end(); ++i)     ...do something with i... in D, but obviously with an associative array. It seems that it's quite easy to iterate through t

Re: Find in assoc array then iterate

2022-10-21 Thread JG via Digitalmars-d-learn
On Friday, 21 October 2022 at 22:03:53 UTC, Kevin Bailey wrote: I'm trying to do this equivalent C++: unordered_map map; for (auto i = map.find(something); i != map.end(); ++i) ...do something with i... in D, but obviously with an associative array. It seems that it's quite ea

Re: Find in assoc array then iterate

2022-10-21 Thread Sergey via Digitalmars-d-learn
On Friday, 21 October 2022 at 22:03:53 UTC, Kevin Bailey wrote: I'm trying to do this equivalent C++: unordered_map map; for (auto i = map.find(something); i != map.end(); ++i) ...do something with i... in D, but obviously with an associative array. It seems that it's quite ea

Find in assoc array then iterate

2022-10-21 Thread Kevin Bailey via Digitalmars-d-learn
I'm trying to do this equivalent C++: unordered_map map; for (auto i = map.find(something); i != map.end(); ++i) ...do something with i... in D, but obviously with an associative array. It seems that it's quite easy to iterate through the whole "map", but not start from the mi

Re: [Help Needed] - Debugging compilation time

2022-10-21 Thread apz28 via Digitalmars-d-learn
On Friday, 21 October 2022 at 16:32:17 UTC, Hipreme wrote: Hey guys, I have been complaining a lot of time right now from D compilation speed at least for my project. I have: - Underused CTFE - Underused Templates - Avoided importing standard libraries - Created a multi module projects for bett

Re: [Help Needed] - Debugging compilation time

2022-10-21 Thread ryuukk_ via Digitalmars-d-learn
Make sure you have the latest version of DMD Make sure your antivirus isn't blocking your files (scanning), it's a common thing with Windows, whitelist dmd folder, your dev folder and dub folder

Re: [Help Needed] - Debugging compilation time

2022-10-21 Thread ryuukk_ via Digitalmars-d-learn
I tried your project: Linux x64 ``` git clone https://github.com/MrcSnm/HipremeEngine.git cd HipremeEngine dub build (once to download dependencies if any) time dub build -f real0m4.604s user0m3.686s sys 0m0.900s ``` 4.6 sec for a FULL rebuild doesn't seem that bad and ``` real

Re: DConf '22: No-Allocated 0-terminated path strings

2022-10-21 Thread Krzysztof Jajeśnica via Digitalmars-d-learn
On Friday, 21 October 2022 at 14:34:47 UTC, ag0aep6g wrote: Nitpick: You cannot iterate a true input range twice. You need a forward range for that. Nitpick²: you don't actually need to iterate the range twice ```d //version=AllowMalloc; auto toCStringThen(alias dg, Range)(Range src) /*nothrow

Re: [Help Needed] - Debugging compilation time

2022-10-21 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 21, 2022 at 04:32:17PM +, Hipreme via Digitalmars-d-learn wrote: > Hey guys, I have been complaining a lot of time right now from D > compilation speed at least for my project. > > I have: > - Underused CTFE > - Underused Templates > - Avoided importing standard libraries > - Creat

[Help Needed] - Debugging compilation time

2022-10-21 Thread Hipreme via Digitalmars-d-learn
Hey guys, I have been complaining a lot of time right now from D compilation speed at least for my project. I have: - Underused CTFE - Underused Templates - Avoided importing standard libraries - Created a multi module projects for better code reuse Those are all the techniques I have tried to

Re: DConf '22: No-Allocated 0-terminated path strings

2022-10-21 Thread ag0aep6g via Digitalmars-d-learn
On Friday, 21 October 2022 at 13:49:01 UTC, cc wrote: ```d //version=AllowMalloc; auto toCStringThen(alias dg, Range)(Range src) /*nothrow*/ if (isInputRange!Range && !isInfinite!Range) { ``` [...] May need to be cleaned up for character types and needs to iterate twice if allocations are goi

DConf '22: No-Allocated 0-terminated path strings

2022-10-21 Thread cc via Digitalmars-d-learn
Catching up on the DConf '22 videos, really enjoyed the tricks Walter presents here for no-allocation strings: [DConf '22: Strawberries and Cream aka Delightful Emergent Properties of D -- Walter Bright](https://www.youtube.com/watch?v=iuP-AWUyjp8) In the Q&A segment, the first question aske

Re: How to pass noncopyable variadic arguments with ref?

2022-10-21 Thread ryuukk_ via Digitalmars-d-learn
On Thursday, 20 October 2022 at 14:03:10 UTC, tchaloupka wrote: Hi, I've found strange behavior where: ```D import std.stdio; struct Foo { @disable this(this); int x; } void test(Foo[] foos...) { foreach (ref f; foos) { writeln(&f, ": ", f.x); f.x = 0; } } void

Alpine: static compilation

2022-10-21 Thread Sergey via Digitalmars-d-learn
Hi D-community. I try to build and run very simple code on Alpine docker image - but have no luck with static builds and LTO. The desired aim is to be able build it similar to C code compilation: ```c gcc leibniz.c -o leibniz -O3 -s -static -flto -march=native -mtune=native -fomit-frame-poi