A New Collections Framework for the Standard Library

Slides:



Advertisements
Similar presentations
Chapter6 LISTS AND STRINGS. Outline 1. List Specifications 2. List Implementations (a) Class Templates (b) Contiguous (c) Simply Linked (d) Simply Linked.
Advertisements

1 Joe Meehean. Ordered collection of items Not necessarily sorted 0-index (first item is item 0) Abstraction 2 Item 0 Item 1 Item 2 … Item N.
A Coherent and Managed Runtime for ML on the SCC KC SivaramakrishnanLukasz Ziarek Suresh Jagannathan Purdue University SUNY Buffalo Purdue University.
Linked Lists... An introduction to creating dynamic data structures.
Preliminaries Attendance sheets –I remembered! HW1 due tonight –progress report Stage 1 due on Friday –progress report.
CMSC 341 Lists 3. 2 Doubly-Linked Lists Option: add pointer to previous node Issues –doubles number of pointers –allows immediate (O(1)) access to previous.
Writing Your Own STL Container Ray Lischner
1 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
Generic Programming Using the C++ Standard Template Library.
CS212: Object Oriented Analysis and Design Lecture 24: Introduction to STL.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
1 Chapter 3 Lists, Stacks, and Queues Reading: Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
1 Linked Lists Assignment What about assignment? –Suppose you have linked lists: List lst1, lst2; lst1.push_front( 35 ); lst1.push_front( 18 ); lst2.push_front(
Linked Lists A formal data structure. Linked Lists Collections of data items “lined up in a row” Inserts and deletes can be done anywhere in the list.
D Language Compiler as a Library
CS212: Object Oriented Analysis and Design
Introduction to olympic programming
STACKS & QUEUES for CLASS XII ( C++).
Data Abstraction: The Walls
COMP 53 – Week Eight Linked Lists.
Cpt S 122 – Data Structures Abstract Data Types
Chapter 12 – Data Structures
UNIT – I Linked Lists.
Linked Lists Chapter 6 Section 6.4 – 6.6
Linked Lists A linked list is a data structure that uses a "chain" of node objects, connected by pointers, to organize a collection of user data values.
Data Structures and Algorithms
CISC181 Introduction to Computer Science Dr
Standard Template Library (STL)
ENERGY 211 / CME 211 Lecture 19 November 3, 2008.
Programmazione I a.a. 2017/2018.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Queues.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Object Oriented Programming COP3330 / CGS5409
Chapter 18: Linked Lists.
Programming with Regions
Generic Lightweight Druntime
Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors
More About Data Types & Functions
Pointers C#, pointers can only be declared to hold the memory addresses of value types int i = 5; int *p; p = &i; *p = 10; // changes the value of i to.
Hassan Khosravi / Geoffrey Tien
Doubly Linked List Implementation
Review & Lab assignments
Data Structures and Algorithms
How to use Strings (way to quick briefing)
Chapter 17: Linked Lists.
CMSC 341 Lists 3.
CMSC 341 Lists 3.
Introduction to C++ Linear Linked Lists
Lists - I The List ADT.
Lists - I The List ADT.
Lecture 16 Section 6.2 Thu, Mar 1, 2007
Objects Managing a Resource
COP 3330 Object-oriented Programming in C++
Linked Lists.
CS410 – Software Engineering Lecture #5: C++ Basics III
COP 3330 Object-oriented Programming in C++
STL List.
ENERGY 211 / CME 211 Lecture 30 December 5, 2008.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Nate Brunelle Today: Style, Collections
Doubly Linked List Implementation
Chapter 3 Lists, Stacks, and Queues
Rethinking the Default Class Hierarchy: an Object’s Tale
Arrays and ArrayLists.
The List Container and Iterators
Abstract Data Types Stacks CSCI 240
STL List.
Presentation transcript:

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

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

Not convinced?

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

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

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

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

Qualifiers 1/3 Support const and immutable ISharedAllocator

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

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

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

Mutable!T 2/2 Mutable!T T mutable const shared immutable

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

Current status SList DList Array Hashtable

Benchmarking 1/2

Benchmarking 2/2

Further work Add more collections Add shared collections Composition scheme

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