Kinds of containers
Nordlöw via Digitalmars-d
digitalmars-d at puremagic.com
Thu Oct 22 00:31:49 PDT 2015
On Wednesday, 21 October 2015 at 11:05:12 UTC, Andrei
Alexandrescu wrote:
> Andrei
Exiting, times ahead!
One thing that has caught my attention lately:
I believe one way of making `std.experimental.allocator` usage
(more) automatic is to add subtypes of containers for specific
limited access patterns.
For instance, some graph algorithms, such a calculating subgraphs,
for instance:
https://github.com/nordlow/justd/blob/master/knet/setops.d#L10
internally uses hashsets (currently implemented as a bool[Value])
for instance:
https://github.com/nordlow/justd/blob/master/knet/setops.d#L15
only require the two primitives:
- bool insert(Value value): returns true if value was stored, not
already existed
- bool contains(Value value)
In this case (when no references are leaked), `HashSet` could be
sub-typed to, say `ExpandableConstantHashSet`, which can @safely
and automatically make use of a `RegionAllocator` for
super-performance.
In this way, even complete beginners in D, could @safely use
Phobos containers to beat C++ performance.
Destroy!
More information about the Digitalmars-d
mailing list