New Core Tutorial

git-svn-id: svn://ultimatepp.org/upp/trunk@10538 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-12-12 10:08:40 +00:00
parent dd88feaf2e
commit 6c22e727de
37 changed files with 3125 additions and 0 deletions

View file

@ -0,0 +1,31 @@
#include "Tutorial.h"
void IndexClient()
{
/// .Index and client types
/// In order to store elements to `Index`, they type must be `Moveable`, have deep copy and
/// defined the `operator==` and a `GetHashValue` function or method to compute the hash
/// code. It is recommended to use `CombineHash` to combine hash values of types that
/// already provide `GetHashValue`:
struct Person : Moveable<Person> {
String name;
String surname;
unsigned GetHashValue() const { return CombineHash(name, surname); }
bool operator==(const Person& b) const { return name == b.name && surname == b.surname; }
Person(String name, String surname) : name(name), surname(surname) {}
Person() {}
};
Index<Person> p;
p.Add(Person("John", "Smith"));
p.Add(Person("Paul", "Carpenter"));
p.Add(Person("Carl", "Engles"));
DUMP(p.Find(Person("Paul", "Carpenter")));
///
}