an implementation of Microsoft's Language integrated query for C++
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
csharp
data
docs
origin @ 96956ae
src
.gitignore
.gitmodules
README.md

README.md

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