1 / 18

A New Collections Framework for the Standard Library

Introducing a novel collections framework for enhanced data handling with a focus on speed, safety, functional style, and seamless integration with Phobos. This innovative framework combines ranges and optional primitives to optimize memory management and ensure safety in operations. Explore the features like reference counting, qualifiers, and primitives in this new approach to building collections in D programming. Join us at DConf 2017 in Berlin to learn more!

eshepherd
Download Presentation

A New Collections Framework for the Standard Library

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Constantin Eduard Stăniloiu University POLITEHNICA of Bucharest eduard.c.staniloiu@gmail.com A New Collections Framework for the Standard Library DConf 2017 Berlin, May 4-7, 2017

  2. Motivation • Do you like • Speed • Safety • Functional style • Range API • Integration with Phobos

  3. Not convinced?

  4. Collection = Range + Optional Primitives “There are no collections, only ranges” • @nogc • Own memory management • Safe • Qualified “When in doubt, do what int[] does”

  5. @nogc • The allocator is not part of the type • IAllocator • ISharedAllocator • Default to theAllocator or processAllocator

  6. Own memory management • Using reference counting • AffixAllocator!(Mallocator, uint) • fronts each allocation with an extra uint • … that’s independently typed

  7. Safety • Must be inferred from the contained type • Memory allocation is a safe operation • Deallocation is unsafe by definition, but RC makes it safe

  8. Qualifiers 1/3 • Support const and immutable • ISharedAllocator

  9. Qualifiers 2/3 • Remember: do what int[] does • Need to store a mutating allocator in an immutable collection • AffixAllocator anyone?

  10. Qualifiers 3/3 • Use an ouroboros allocator prefix Store in prefix • Must be reference counted

  11. Mutable!T 1/2 • Reference counted struct • Enables mutable T in immutable constructs

  12. Mutable!T 2/2

  13. Primitives • Range API • empty, front, popFront • tail • insert, remove • a ~ b, a ~= b, ++a[i], etc. • isUnique • get/setAllocator

  14. Current status • SList • DList • Array • Hashtable

  15. Benchmarking 1/2

  16. Benchmarking 2/2

  17. Further work • Add more collections • Add sharedcollections • Composition scheme

  18. Conclusions A new collections framework that is • Fast • Safe • @nogc • Qualified

More Related