-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (35 loc) · 1.58 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Created by angel on 01/02/17.
//
#include "CommonHeaders.h"
#include "Contact.h"
#include "LinqCore.h"
int main() {
// We set up some test data
int numbersArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::vector<float> grades {12.75, 14.32, 16.76, 18.22};
std::vector<Contact> contacts {Contact(1, "John", "Doe", "01/01/1985", "[email protected]"),
Contact(2, "Matt", "Roberts", "07/07/1975", "[email protected]"),
Contact(3, "Jane", "Doe", "07/10/1980", "[email protected]")};
Contact contactsArray[] = {Contact(1, "Joe", "Bloggs", "10/10/1980", "[email protected]"),
Contact(2, "Karly", "Smith", "05/05/1980", "[email protected]"),
Contact(3, "Michael", "White", "05/05/1980", "[email protected]")};
// Where method
auto where = LinqCore<Contact>::Where(contacts, [&](Contact c) -> bool {return c.LastName == "Doe";});
// Average method
auto average = LinqCore<float>::Average(grades);
// Sum method
auto sum = LinqCore<float>::Sum(grades);
// Cast into std::vector<Contact>
auto castContact = LinqCore<Contact>::Cast(contactsArray, 3);
// Cast into std::vector<int>
auto castInt = LinqCore<int>::Cast(numbersArray, 10);
// Count method
auto count = LinqCore<Contact>::Count(contacts, [&](Contact c) -> bool {return c.LastName == "Doe";});
// Max method
auto max = LinqCore<int>::Max(castInt);
// Min method
auto min = LinqCore<int>::Min(castInt);
getchar();
return 0;
}