Skip to content
/ CINQ Public

an implementation of Microsoft's Language integrated query for C++

Notifications You must be signed in to change notification settings

jeb2239/CINQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CINQ: C++ Integrated Query

An implementation of Microsoft's Language Integrated Query for C++.

This library is our class project for Bjarne Stroustrup's Language Library Design class.

Why LINQ?

LINQ allows you to simplify data processing code. For example, both snippets below do the same thing --- find the temperatures of the five coldest rainy days in the provided data set.

Normal version:

vector<weather_point> result;
for (auto& data : weather_data)
{
     if (data.rain) result.push_back(data);
}
        
sort(result.begin(), result.end(),
    [](const auto &a, const auto &b) { return a.temp_min < b.temp_min; });
        
vector<weather_point> five;
for (size_t i = 0; i < 5; i++) five.push_back(result[i]);
        
vector<int> temps;
for (auto& data : five) temps.push_back(data.temp_min);

The LINQ version is much easier to understand:

cinq::from(weather_data)
     .where([](const weather_point& w) { return w.rain; })
     .order_by([](const weather_point& w) { return w.temp_min; })
     .take(5)
     .select([](const weather_point& w) { return w.temp_min; })
     .to_vector();

Intrigued? Please take a look at our documentation linked below.

Learn more

Authors

About

an implementation of Microsoft's Language integrated query for C++

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published