lib/realtime: Add Timespec::to_f (and to_s) so one can print them easyly

Signed-off-by: Jean Privat <jean@pryen.org>
lib/trees: improve bintrees efficiency

First, comment potential slow asserts in the hot-path.
These asserts are needed only to check that the implementation is
correct.

Second, use a single `<=>` instead of doing multiple comparisons.
So reduce the total number of comparisons.

On a real instance (IA-related problems), the gain is the following:

RBTreeMap, 8738 insertions, 24855 accesses
Before: 2.54s
After: 0.07s (so, in the noise)

Signed-off-by: Jean Privat <jean@pryen.org>
lib/std: Float has their own `==` and Comparable-related methods

Signed-off-by: Jean Privat <jean@pryen.org>
comp: fix shortcut-range (succ was removed)

Signed-off-by: Jean Privat <jean@pryen.org>
comp: shortcut-range work also on closed ranges

Signed-off-by: Jean Privat <jean@pryen.org>
tests: update sav related to lines in kernel

Signed-off-by: Jean Privat <jean@pryen.org>
transform: do not transform rranges in for; this reactivates the short-range optimisation

Signed-off-by: Jean Privat <jean@pryen.org>
lib/std: add fast implementation for Array::==

Signed-off-by: Jean Privat <jean@pryen.org>
lib/std: add ArrayCmp to easily compare arrays of comparable elements.

Signed-off-by: Jean Privat <jean@pryen.org>
tests: update because line changes in errors.

Signed-off-by: Jean Privat <jean@pryen.org>
Merge: Reactivate shortcut range

Since transform.nit and the Numeric class (that renamed Discrete::succ into something else) the optimization that shortcut range was innefective.

After reactivating them, Perf increase is approx 5%.

Pull-Request: #657
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: Improve Floats perfs

Improve perf for those who do not need excessive boxing of floats

Pull-Request: #656
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: lib/trees: improve bintrees efficiency

First, comment potential slow asserts in the hot-path.
These asserts are needed only to check that the implementation is
correct.

Second, use a single `<=>` instead of doing multiple comparisons.
So reduce the total number of comparisons.

On a real instance (IA-related problems), the gain is the following:

RBTreeMap, 8738 insertions, 24855 accesses
Before: 2.54s
After: 0.07s (so, in the noise)

Pull-Request: #653
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: Compare arrays

Improve comparaisons in arrays

Pull-Request: #658
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
lib/ai: introduce the ai library with `backtrack` as the first module

For information, the logic is extracted from the solver of friendz.

Signed-off-by: Jean Privat <jean@pryen.org>
lib/ai: add the eight-queen problem as an example

Signed-off-by: Jean Privat <jean@pryen.org>
friendz: use ai::backtrack instead of the ad-hoc solver

Signed-off-by: Jean Privat <jean@pryen.org>
friendz: add solver_cmd for solve from command line

Signed-off-by: Jean Privat <jean@pryen.org>
Merge: AI backtrack

The first part of the artificial intelligence library.

This provides a framework for a basic backtracking algorithm.

It is used in a standard 8 queens problem (quite elegant!), but also replace the specific solver in friendz (the new solver is a little faster in fact)

Pull-Request: #642
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/json_serialization: support Arrays

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>