O(1) "popAny" for associative array?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 11 10:41:12 PST 2014


On Thu, Dec 11, 2014 at 10:36:02AM -0800, H. S. Teoh via Digitalmars-d-learn wrote:
[...]
> 	auto mykey = myarray.byKey().front;
> 	myarray.remove(mykey);
[...]

Ah, I forgot that you need to check .empty on the range returned by
byKey before accessing .front. Thanks to Ali for pointing that out. :-)
In this case, though, you *could* just check myarray.empty directly
instead.


T

-- 
Why are you blatanly misspelling "blatant"? -- Branden Robinson


More information about the Digitalmars-d-learn mailing list