You've likely used the STL before, and you are probably comfortable using std::vector some algorithms, but you may not be quite so comfortable with STL iterators. What even are "single pass writable iterators"? What does that mean to me as a user of the STL?
In this talk, we will motivate the iterator concept hierarchy as it exists in the STL today by looking at useful algorithms and how they traverse their input and output ranges. We will take these concrete examples and slowly begin to abstract, building up the STL iterator concepts, step-by-step.
After presenting the iterator concepts that exist in the STL today, we will build up to two further iterator concepts by looking at useful algorithms and then generalizing from them. First, we will motivate contiguous iterators, which have been voted into the C++17 working draft. Then, we will motivate a less-commonly known iterator concept, segmented iterators, and show how they can help us write parallel and cache-aware algorithms.
Climbing the Abstract Syntax Tree (PHP South Africa 2017)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run. To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before. After seeing this talk, you'll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code. (*actual magic or time-warp not guaranteed)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)James Titcumb
Security is an enormous topic, and it’s really, really complicated. If you’re not careful, you’ll find yourself vulnerable to any number of attacks which you definitely don’t want to be on the receiving end of. This talk will give you just a taster of the vast array of things there is to know about security in modern web applications, such as writing secure PHP web applications and securing a Linux server. Whether you are writing anything beyond a basic brochure website, or even developing a complicated business web application, this talk will give you insights to some of the things you need to be aware of.
Climbing the Abstract Syntax Tree (PHP South Africa 2017)James Titcumb
The new Abstract Syntax Tree (AST) in PHP 7 means the way our PHP code is being executed has changed. Understanding this new fundamental compilation step is key to understanding how our code is being run. To demonstrate, James will show how a basic compiler works and how introducing an AST simplifies this process. We’ll look into how these magical time-warp techniques* can also be used in your code to introspect, analyse and modify code in a way that was never possible before. After seeing this talk, you'll have a great insight as to the wonders of an AST, and how it can be applied to both compilers and userland code. (*actual magic or time-warp not guaranteed)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)James Titcumb
Security is an enormous topic, and it’s really, really complicated. If you’re not careful, you’ll find yourself vulnerable to any number of attacks which you definitely don’t want to be on the receiving end of. This talk will give you just a taster of the vast array of things there is to know about security in modern web applications, such as writing secure PHP web applications and securing a Linux server. Whether you are writing anything beyond a basic brochure website, or even developing a complicated business web application, this talk will give you insights to some of the things you need to be aware of.
Simply Business is starting to look into new tools to improve some of our mission-critical systems. There is one application, which would hugely benefit from the concurrency and fault tolerance model offered by languages like Elixir.
To increase awareness and gauge interest in the technology, we will have a bootcamp dedicated to giving us more insights into how to build and architect applications using Elixir and OTP.
It is meant to aim for slightly more advanced concepts, so in order to prepare rest of the team to be able to read the code and have some basic understanding of constructs and tooling - we have organised a LevelUP session, to talk exactly about that...
How to avoid Go gotchas - Ivan Daniluk - Codemotion Milan 2016Codemotion
One of the primary strengths of Go programming language is a built-in first-class support for concurrency. We're going to learn about it in a completely new way, using interactive 3D visualizations, which help us understand the complex but astonishing world of modern concurrent software. We'll see what’s happening inside the real code—from a simple “Hello, World” to real production-level high-loaded servers, and learn different approaches and concurrency patterns that are used for building concurrent pipelines and algorithms. And we'll do it all in 3D!
Oxygine 2 d objects,events,debug and resourcescorehard_by
Доклад будет посвящен созданию/удалению и взаимодействию игровых объектах, о стандартных и кастомизированных смартпоинтерах. Какими вещами пользоваться чтобы получить debug информацию о том что происходит в игре. Будут приведены примеры шаблонов игрового проектирования. Несколько слов о интересных редакторах игровых ресурсов: MapEditor.com, Astralax.ru
Dip Your Toes in the Sea of Security (PHP MiNDS January Meetup 2016)James Titcumb
Security is an enormous topic, and it’s really, really complicated. If you’re not careful, you’ll find yourself vulnerable to any number of attacks which you definitely don’t want to be on the receiving end of. This talk will give you just a taster of the vast array of things there is to know about security in modern web applications, such as writing secure PHP web applications and securing a Linux server. Whether you are writing anything beyond a basic brochure website, or even developing a complicated business web application, this talk will give you insights to some of the things you need to be aware of.
1- Modeling Hierarchy
2- Creating Testbenches
Skills gained:
1- Reuse design units several times in a design hierarchy
2- Automate testing of design units
This is part of VHDL 360 course
Simply Business is starting to look into new tools to improve some of our mission-critical systems. There is one application, which would hugely benefit from the concurrency and fault tolerance model offered by languages like Elixir.
To increase awareness and gauge interest in the technology, we will have a bootcamp dedicated to giving us more insights into how to build and architect applications using Elixir and OTP.
It is meant to aim for slightly more advanced concepts, so in order to prepare rest of the team to be able to read the code and have some basic understanding of constructs and tooling - we have organised a LevelUP session, to talk exactly about that...
How to avoid Go gotchas - Ivan Daniluk - Codemotion Milan 2016Codemotion
One of the primary strengths of Go programming language is a built-in first-class support for concurrency. We're going to learn about it in a completely new way, using interactive 3D visualizations, which help us understand the complex but astonishing world of modern concurrent software. We'll see what’s happening inside the real code—from a simple “Hello, World” to real production-level high-loaded servers, and learn different approaches and concurrency patterns that are used for building concurrent pipelines and algorithms. And we'll do it all in 3D!
Oxygine 2 d objects,events,debug and resourcescorehard_by
Доклад будет посвящен созданию/удалению и взаимодействию игровых объектах, о стандартных и кастомизированных смартпоинтерах. Какими вещами пользоваться чтобы получить debug информацию о том что происходит в игре. Будут приведены примеры шаблонов игрового проектирования. Несколько слов о интересных редакторах игровых ресурсов: MapEditor.com, Astralax.ru
Dip Your Toes in the Sea of Security (PHP MiNDS January Meetup 2016)James Titcumb
Security is an enormous topic, and it’s really, really complicated. If you’re not careful, you’ll find yourself vulnerable to any number of attacks which you definitely don’t want to be on the receiving end of. This talk will give you just a taster of the vast array of things there is to know about security in modern web applications, such as writing secure PHP web applications and securing a Linux server. Whether you are writing anything beyond a basic brochure website, or even developing a complicated business web application, this talk will give you insights to some of the things you need to be aware of.
1- Modeling Hierarchy
2- Creating Testbenches
Skills gained:
1- Reuse design units several times in a design hierarchy
2- Automate testing of design units
This is part of VHDL 360 course
My talk at DrupalCon Chicago, 2011. http://chicago2011.drupal.org/sessions/visual-hierarchy-1-2-3-must-be-important
Whether you're designing a homepage, the next Views interface, or a car dashboard, visual hierarchy is one of the most important design principles that comes into play. We'll look at real world examples of visual hierarchy gone good and bad and some basic fundamentals, tips and tricks to ensure that the important things win in your designs.
We'll dive into Drupal for some real world examples of visual hierarchy decisions that affect us Drupalers every day. We'll also take a look at some of the unique challenges and benefits when establishing visual hierarchy on mobile devices like smart phones and tablets.
Yale Art + Architecture Building - Case StudyVikram Bengani
A case study from the perspective of architecture of the Architecture Building at Yale University. Performed as part of the architectural education campus design project in the year three of the B. Architecture course.
How to add an interactive shell (remote, too) to a C++ application by using my open-source C++14 library:
https://github.com/daniele77/cli
In the slide deck you can learn how to use it, how does it work, and find some thoughts about C++ design and patterns used by the library.
This set of slides introduces the reader to a subset of the C++ Standard Library called the Standard Template Library (STL). The STL provides a collection of parameterized containers and algorithms, and it is the most successful example of an approach to programming called generic programming. In this presentation, we aim at studying the ideals and concepts of the STL by re-implementing small parts of the library. Specifically, we first show how we can discover requirements on types in order to devise generic algorithms. Then, we focus on how to make algorithms independent of containers through the pivotal abstraction of iterators. To this end, we replicate the standard algorithm for finding the minimum in a sequence (min_element), which we subsequently match with a custom forward iterator over intrusive linked lists of integers. Finally, we see how function objects can be used to customize containers and algorithms alike. This allows us to deepen our understanding of ordering relations, and, in particular, to introduce the concept of strict weak orderings.
So I am writing a CS code for a project and I keep getting cannot .pdfezonesolutions
So I am writing a CS code for a project and I keep getting \"cannot open file\" I know I put it into
my code, but I don\'t know why it won\'t execute after i input ./a.out I put in gcc -Wall
contents3.c and no errors or warnings pop up. So I figure everything is working right. But after
that, I get \"Cannot open file\". So I am wondering what I can do to get this settled out properly. I
am putting the outcome of the project and my code. Please someone help me!
#include
#include
#include
#include
#include
#include
int len = 0;
int sp = 0;
int lwrcaseCount = 0;
int uprcaseCount = 0;
int digitCount = 0;
int specialCount = 0;
char data[200];
int frequency[84];
int sortFrequency[84][2];
char string[] =
\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\\\"#$%&\'()*+,-
./:;<=>?@[/]^_`{|}~\";
//printf(\"\ \");
//To sort based on frequency of characters
/*void sort()
{
int max, loc, temp, x, y;
//Loops till end - 1 position of the frequency array
for(x = 0; x <= 84 - 1; x++)
{
//Initializes the max to the x position of the frequency array assuming it as maximum
max = frequency[x];
//Initializes of loc to x assuming location x contains the maximum value
loc = x;
//Loops through x + 1 to length - 1 of frequency array
for(y = x + 1; y <= 95 -1; y++)
{
//If current position of the frequency of the array is greater than the max
//then update the max with the current value of frequency and update the loc
if(frequency[y] > max)
{
max = frequency[y];
loc = y;
}//end of if
}//end of for loop
//If loc is not x then swap
if(loc != x)
{
temp = frequency[x];
frequency[x] = frequency[loc];
frequency[loc] = temp;
}//end of if
//Store the location of the maximum value in the zero column position of row x
sortFrequency[x][0]= loc;
//Store the maximum value in the first column position of row x
sortFrequency[x][1] = max;
}//end of for loop
}//end of function*/
void sort()
{
for(int i = 0; i < 84; i++)
{
sortFrequency[i][0] = i;
sortFrequency[i][1] = frequency[i];
}
for(int i = 0; i < 84-1; i++)
for(int j = 0; j < 84-i-1; j++)
if(sortFrequency[j][1] < sortFrequency[j+1][1])
{
int temp = sortFrequency[j][1];
sortFrequency[j][1] = sortFrequency[j+1][1];
sortFrequency[j+1][1] = temp;
temp = sortFrequency[j][0];
sortFrequency[j][0] = sortFrequency[j+1][0];
sortFrequency[j+1][0] = temp;
}
}
//To count frequency of each character
void frequencyCount()
{
int c, d;
//Loops till the length of the inputed data
for(c = 0; c < len; c++)
{
//Loops from 33 to 126 which is the ascii values of required characters range
for(d = 0; d < 84; d++)
{
//If the data in the current position is equal to the acii value
if(data[c] == string[d])
//Frequency 0 position is equal to 33 ascii.
//So 33 is deducted
frequency[d]++;
}//end of for loop
}//end of for loop
}//End of function
//Initializes the frequency array to zero
void initialize()
{
int c;
for(c = 0; c < 84; c++)
frequency[c] = 0;
}
//Read the file which contains data
void readFile()
{
//File pointer created
FILE *fptr;
char ch;
//Fi.
A C# coding challenge to solve a range of mazes with differing dimensions and styles. The total run time was considerably less than a target maximum run time.
Introduction to programming - class 11Paul Brebner
High School level (years 9-10 in Australia, ages 14-16) introduction to programming course, based on the language Processing, includes class material, exercises, examples, and tests. Course ran for 2 terms in 2014. Feel free to use as is, borrow ideas, etc. 11th class and Quiz 2.
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
What do threads, atomic variables, mutexes, and conditional variables have in common? They are the basic building blocks of any concurrent application in C++, which are even for the experienced C++ programmers a big challenge. This massively changed with C++17 and change even more with C++20/23. What did we get with C++17, what can we hope for with C++20/23? With C++17, most of the standard template library algorithms are available in sequential, parallel, and vectorised variants. With the upcoming standards, we can look forward to executors, transactional memory, significantly improved futures and coroutines. To make it short. These are just the highlights from the concurrent and parallel perspective. Thus there is the hope that in the future C++ abstractions such as executors, transactional memory, futures and coroutines are used and that threads, atomic variables, mutexes and condition variables are just implementation details.
This talk was part tongue in cheek, part serious, but entirely fun and given twice as a lightning talk - once at Europython & once at the ACCU python uk 05. It presents a generic python like language parser which does actually work. Think of it as an alternative to brackets in Lisp!
Python's "batteries included" philosophy means that it comes with an astonishing amount of great stuff. On top of that, there's a vibrant world of third-party libraries that help make Python even more wonderful. We'll go on a breezy, example-filled tour through some of my favorites, from treasures in the standard library to great third-party packages that I don't think I could live without, and we'll touch on some of the fuzzier aspects of the Python culture that make it such a joy to be part of.
Similar to From Zero to Iterators: Building and Extending the Iterator Hierarchy in a Modern, Multicore World (20)
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Transform Your Communication with Cloud-Based IVR SolutionsTheSMSPoint
Discover the power of Cloud-Based IVR Solutions to streamline communication processes. Embrace scalability and cost-efficiency while enhancing customer experiences with features like automated call routing and voice recognition. Accessible from anywhere, these solutions integrate seamlessly with existing systems, providing real-time analytics for continuous improvement. Revolutionize your communication strategy today with Cloud-Based IVR Solutions. Learn more at: https://thesmspoint.com/channel/cloud-telephony
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j
Dr. Jesús Barrasa, Head of Solutions Architecture for EMEA, Neo4j
Découvrez les dernières innovations de Neo4j, et notamment les dernières intégrations cloud et les améliorations produits qui font de Neo4j un choix essentiel pour les développeurs qui créent des applications avec des données interconnectées et de l’IA générative.
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
Utilocate offers a comprehensive solution for locate ticket management by automating and streamlining the entire process. By integrating with Geospatial Information Systems (GIS), it provides accurate mapping and visualization of utility locations, enhancing decision-making and reducing the risk of errors. The system's advanced data analytics tools help identify trends, predict potential issues, and optimize resource allocation, making the locate ticket management process smarter and more efficient. Additionally, automated ticket management ensures consistency and reduces human error, while real-time notifications keep all relevant personnel informed and ready to respond promptly.
The system's ability to streamline workflows and automate ticket routing significantly reduces the time taken to process each ticket, making the process faster and more efficient. Mobile access allows field technicians to update ticket information on the go, ensuring that the latest information is always available and accelerating the locate process. Overall, Utilocate not only enhances the efficiency and accuracy of locate ticket management but also improves safety by minimizing the risk of utility damage through precise and timely locates.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
DDS Security Version 1.2 was adopted in 2024. This revision strengthens support for long runnings systems adding new cryptographic algorithms, certificate revocation, and hardness against DoS attacks.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Takashi Kobayashi and Hironori Washizaki, "SWEBOK Guide and Future of SE Education," First International Symposium on the Future of Software Engineering (FUSE), June 3-6, 2024, Okinawa, Japan
Zoom is a comprehensive platform designed to connect individuals and teams efficiently. With its user-friendly interface and powerful features, Zoom has become a go-to solution for virtual communication and collaboration. It offers a range of tools, including virtual meetings, team chat, VoIP phone systems, online whiteboards, and AI companions, to streamline workflows and enhance productivity.
WhatsApp offers simple, reliable, and private messaging and calling services for free worldwide. With end-to-end encryption, your personal messages and calls are secure, ensuring only you and the recipient can access them. Enjoy voice and video calls to stay connected with loved ones or colleagues. Express yourself using stickers, GIFs, or by sharing moments on Status. WhatsApp Business enables global customer outreach, facilitating sales growth and relationship building through showcasing products and services. Stay connected effortlessly with group chats for planning outings with friends or staying updated on family conversations.
Atelier - Innover avec l’IA Générative et les graphes de connaissancesNeo4j
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Allez au-delà du battage médiatique autour de l’IA et découvrez des techniques pratiques pour utiliser l’IA de manière responsable à travers les données de votre organisation. Explorez comment utiliser les graphes de connaissances pour augmenter la précision, la transparence et la capacité d’explication dans les systèmes d’IA générative. Vous partirez avec une expérience pratique combinant les relations entre les données et les LLM pour apporter du contexte spécifique à votre domaine et améliorer votre raisonnement.
Amenez votre ordinateur portable et nous vous guiderons sur la mise en place de votre propre pile d’IA générative, en vous fournissant des exemples pratiques et codés pour démarrer en quelques minutes.
10. The goal
✓ I’ve heard of iterators before.
✓ I’ve used iterators before.
(✓) I love iterators.
× I think iterators are fundamental to computer science.
1
11. The goal
✓ I’ve heard of iterators before.
✓ I’ve used iterators before.
(✓) I love iterators.
× I think iterators are fundamental to computer science. (Ask me offline!)
1
12. How we’ll get there
Iterators 101: Introduction to Iterators
Iterators 301: Advanced Iterators
2
13. How we’ll get there
Iterators 101: Introduction to Iterators
Iterators 301: Advanced Iterators
2
14. How we’ll get there
Iterators 101: Introduction to Iterators
Iterators 301: Advanced Iterators
Generic Programming
2
15. What this talk is not
• An introduction to the STL.
• A comprehensive guide to Concepts Lite.
3
18. A simple starting point
template <typename T>
T* copy(T const* in, T const* in_end,
T* out, T* out_end)
{
while (in != in_end && out != out_end) *out++ = *in++;
return out;
}
5
19. A simple starting point
auto source = array<T, 5>{ /* ... */ };
auto destination = array<T, 10>{ /* ... */ };
copy(
&source[0], &source[0] + size(source),
&destination[0], &destination[0] + size(destination)
);
6
20. But we don’t just deal with arrays…
template <typename T>
struct node
{
T value;
node* next;
};
7
21. But we don’t just deal with arrays…
template <typename T>
struct node
{
T value;
node* next;
};
T{…} T{…} T{…} T{…} T{…} ∅
7
22. But we don’t just deal with arrays…
template <typename T>
node<T>* copy(node<T> const* in, node<T> const* in_end,
node<T>* out, node<T>* out_end)
{
while (in != in_end && out != out_end) {
out->value = in->value;
in = in->next;
out = out->next;
}
return out;
}
8
23. But we don’t just deal with arrays…
template <typename T>
T* copy(node<T> const* in, node<T> const* in_end,
T* out, T* out_end)
{
while (in != in_end && out != out_end) {
*out++ = in->value;
in = in->next;
}
return out;
}
9
24. But we don’t just deal with arrays…
template <typename T>
ostream& copy(T const* in, T const* in_end, ostream& out)
{
while (in != in_end && out) out << *in++;
return out;
}
10
49. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
28
50. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
Equality Comparison
28
51. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
Assignment
29
52. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
Construction
30
53. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
Destruction
31
54. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
successor()
32
55. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
source()
33
56. What do we need?
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
sink()
34
66. Concepts!
template <typename T>
concept bool Regular =
is_default_constructible_v<T>
&& is_copy_constructible_v<T>
&& is_destructible_v<T>
&& is_copy_assignable_v<T>
&& ∀x, y ∈ T:
1. x == y can be used in boolean contexts
2. == induces an equivalence relation on T
3. Iff x == y, x and y represent the same value
;
38
67. Concepts!
template <typename T>
concept bool Regular =
is_default_constructible_v<T>
&& is_copy_constructible_v<T>
&& is_destructible_v<T>
&& is_copy_assignable_v<T>
&& requires(T x, T y) {
1. x == y can be used in boolean contexts
2. == induces an equivalence relation on T
3. Iff x == y, x and y represent the same value
};
39
68. Concepts!
template <typename T>
concept bool Regular =
is_default_constructible_v<T>
&& is_copy_constructible_v<T>
&& is_destructible_v<T>
&& is_copy_assignable_v<T>
&& requires(T x, T y) {
{ x == y } -> bool;
2. == induces an equivalence relation on T
3. Iff x == y, x and y represent the same value
};
40
69. Concepts!
template <typename T>
concept bool Regular =
is_default_constructible_v<T>
&& is_copy_constructible_v<T>
&& is_destructible_v<T>
&& is_copy_assignable_v<T>
&& requires(T x, T y) {
{ x == y } -> bool;
// == induces an equivalence relation on T
// Iff x == y, x and y represent the same value
};
41
72. Concepts!
template <typename I>
concept bool Iterator =
Regular<I> &&
requires (I i) {
{ successor(i) } -> I; // O(1)
// successor() may mutate other iterators.
};
44
73. Concepts!
template <typename InputIterator, typename OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
45
74. Concepts!
template <typename InputIterator, typename OutputIterator>
requires Iterator<InputIterator>
&& Readable<InputIterator>
&& Iterator<OutputIterator>
&& Writable<OutputIterator>
OutputIterator copy(InputIterator in, InputIterator in_end
OutputIterator out, OutputIterator out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
46
75. Concepts!
template <typename In, typename Out>
requires Iterator<In>
&& Readable<In>
&& Iterator<Out>
&& Writable<Out>
Out copy(In in, In in_end, Out out, Out out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
47
76. Concepts!
template <Iterator In, Iterator Out>
requires Readable<In> && Writable<Out>
Out copy(In in, In in_end, Out out, Out out_end)
{
while (in != in_end && out != out_end) {
sink(out) = source(in);
out = successor(out);
in = successor(in);
}
return out;
}
48
77. More algorithms
template <Iterator It>
requires Writable<It>
void fill(It it, It it_end, value_type<It> const& x)
{
while (in != in_end) {
sink(out) = x;
it = successor(it);
}
}
49
78. More algorithms
template <Iterator It, Function<value_type<It>, value_type<It>> Op>
requires Readable<It>
auto fold(It it, It it_end, value_type<It> acc, Op op)
{
while (in != in_end) {
acc = op(acc, source(it));
it = successor(it);
}
return acc;
}
50
79. More algorithms
template <Iterator It>
requires Readable<It>
It find_first(It it, It it_end, value_type<It> const& value)
{
while (it != it_end && source(it) != value)
it = successor(it);
return it;
}
51
89. Moving Forward
Proposition
If a type T models ForwardIterator, it also models Iterator.
A ForwardIterator is just an Iterator that doesn’t mutate other iterators in
successor()!
56
97. Backing Up
Proposition
If a type T models BidirectionalIterator, it also models
ForwardIterator.
A BidirectionalIterator has a successor() function that does not
mutate other iterators.
61
98. Backing Up
Proposition
If a type T models BidirectionalIterator, its dual also models
BidirectionalIterator.
62
99. Backing Up
Proposition
If a type T models BidirectionalIterator, its dual also models
BidirectionalIterator.
Let’s define a type whose successor() is our old predecessor() and whose
predecessor() is our old successor(). This new type also models
BidirectionalIterator.
62
100. Backing Up
Proposition
If a type T models BidirectionalIterator, its dual also models
BidirectionalIterator.
Let’s define a type whose successor() is our old predecessor() and whose
predecessor() is our old successor(). This new type also models
BidirectionalIterator.
We call the dual of a BidirectionalIterator a reverse iterator.
62
103. Jumping Around
template <ForwardIterator It>
void increment(It& i, size_t n)
{
// Precondition: n >= 0
for (auto i = 0; i < n; ++i) i = successor(i);
}
void increment(auto*& i, size_t n)
{
// Precondition: n >= 0
i += n;
}
63
104. Jumping Around
template <BidirectionalIterator It>
void decrement(It& i, size_t n)
{
// Precondition: n >= 0
for (auto i = 0; i < n; ++i) i = predecessor(i);
}
void decrement(auto*& i, size_t n)
{
// Precondition: n >= 0
i -= n;
}
64
105. Jumping Around
template <typename I>
concept bool RandomAccessIterator =
Regular<I>
&& WeaklyOrdered<I>
&& requires (I i, I j, size_t n) {
{ i + n } -> I; // O(1)
// i + 0 == i if n == 0
// i + n == successor(i) + n - 1 if n > 0
// i + n == predecessor(i) + n + 1 if n < 0
{ i - n } -> I; // O(1)
// i - 0 == i if n == 0
// i - n == predecessor(i) - (n - 1) if n > 0
// i - n == successor(i) - (n + 1) if n < 0
{ i - j } -> size_t; // O(1)
// i + (i - j) = i
};
65
106. Jumping Around
template <RandomAccessIterator It>
requires Readable<It> && WeaklyOrdered<value_type<It>>
I upper_bound(It it, It it_end, value_type<It> x)
{
// Base case.
if (it == it_end) return it_end;
// mid_dist is always less than or equal to end - begin,
// because of integer division
auto mid_dist = (it_end - it) / 2;
auto mid = it + mid_dist;
// Reduce problem size.
if (source(mid) <= x) return upper_bound(mid + 1, it_end, x);
else return upper_bound( it, mid + 1, x);
}
66
108. Jumping Around
Proposition
If a type T models RandomAccessIterator, it also models
BidirectionalIterator.
Let’s define successor() on an object x of type T to return x + 1. Similarly,
let’s define predecessor() to return x - 1.
67
109. The story so far
Iterator
Forward
Bidir
Random
68
113. Let’s look at the concept
template <typename I>
concept bool RandomAccessIterator =
Regular<I>
&& WeaklyOrdered<I>
&& requires (I i, I j, size_t n) {
{ i + n } -> I; // O(1)
// i + 0 == i if n == 0
// i + n == successor(i) + n - 1 if n > 0
// i + n == predecessor(i) + n + 1 if n < 0
{ i - n } -> I; // O(1)
// i - 0 == i if n == 0
// i - n == predecessor(i) - (n - 1) if n > 0
// i - n == successor(i) - (n + 1) if n < 0
{ i - j } -> size_t; // O(1)
// i + (i - j) = i
};
69
115. A counterexample
template <Regular T>
struct segmented_array {
vector< vector<T> > data;
// where each inner vector except the last has size segsize
};
70
121. What does contiguous mean?
auto i = /* ... */;
auto j = /* ... */;
pointer_from(i + n) == pointer_from(i) + n;
pointer_from(i - n) == pointer_from(i) - n;
pointer_from(i - j) == pointer_from(i) - pointer_from(j);
73
122. What does contiguous mean?
auto i = /* ... */;
auto j = /* ... */;
pointer_from(i + n) == pointer_from(i) + n;
pointer_from(i - n) == pointer_from(i) - n;
pointer_from(i - j) == pointer_from(i) - pointer_from(j);
There must be an homomorphism pointer_from that preserves the range
structure.
73
124. The slightly less simple homomorphism
template <typename T>
using base_offset_iterator = pair<T*, size_t>;
auto* pointer_from(base_offset_iterator<auto> i)
{
return i.first + i.second;
}
75
125. Looks like we have a new concept!
template <typename T>
concept bool ContiguousIterator =
RandomAccessIterator<T>
&& requires (T i) {
typename value_type<T>;
{ pointer_from(i) } -> value_type<T> const*;
// pointer_from homomorphism preserves range
// structure
};
76
126. Looks like we have a new concept!
template <ContiguousIterator In, ContiguousIterator Out>
requires Readable<In> && Writable<Out>
&& is_same_v< value_type<In>, value_type<Out> >
&& is_trivially_copyable_v< value_type<In> >
Out copy(In in, In in_end, Out out, Out out_end)
{
auto count = min( in_end - in, out_end - out );
memmove(pointer_from(out), pointer_from(in), count);
return out_end;
}
77
128. Segmentation Problems
template <Regular T>
struct segmented_array {
vector< vector<T> > data;
// where each inner vector except the last has size segsize
};
78
129. Segmentation Problems
template <SegmentedIterator In, Iterator Out>
requires Readable<In> && Writable<Out>
Out copy(In in, In in_end, Out out, Out out_end)
{
auto seg = segment(in);
auto seg_end = segment(in_end);
if (seg == seg_end) copy(local(in), local(in_end), out, out_end);
else {
out = copy(local(in), end(seg), out, out_end);
seg = successor(seg);
while (seg != seg_end) {
out = copy(begin(seg), end(seg), out, out_end);
seg = successor(seg);
}
return copy(begin(seg), local(in_end), out, out_end);
}
}
79
133. SegmentedIterators are great for parallelization.
template <RandomAccessIterator In, SegmentedIterator Out>
requires Readable<In> && Writable<Out>
&& RandomAccessIterator<Out>
Out copy(In in, In in_end, Out out, Out out_end)
{
auto& task_pool = get_global_task_pool();
auto seg = segment(out);
auto seg_end = segment(out_end);
if (seg == seg_end) {
// ...
} else {
// ...
}
}
82
134. SegmentedIterators are great for parallelization.
if (seg == seg_end) {
return copy(in, in_end, local(out), local(out_end));
} else {
// ...
}
83
135. SegmentedIterators are great for parallelization.
} else {
task_pool.add_task(copy, in, in_end, local(out), end(seg_end));
seg = successor(seg);
in = in + min(in_end - in, end(seg_end) - local(out));
while (seg != seg_end) {
task_pool.add_task(copy, in, in_end, begin(seg), end(seg));
seg = successor(seg);
in = in + min(in_end - in, end(seg) - begin(seg));
}
task_pool.add_task(copy, in, in_end, begin(seg), local(out_end));
return out + min(in_end - in, local(out_end) - begin(out));
}
84
143. Cache-awareness
Since,
• each thread is fed its own set of cache lines,
• no two threads will be writing to the same cache lines,
• no false-sharing.
86
145. References
• Austern, Matthew H (1998). Segmented Iterators and Hierarchical Algorithms.
In Proceedings of Generic Programming: International Seminar, Dagstuhl
Castle, Germany.
• Liber, Nevin (2014). N3884 — Contiguous Iterators: A Refinement of Random
Access Iterators.
• Stepanov, Alexander and Paul McJones (2009). Elements of Programming.
87