Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.85 KB

overview.md

File metadata and controls

42 lines (28 loc) · 1.85 KB

Overview

Jngen is a library which helps you to generate standard objects for competitive problems: trees, graphs, strings and so. For some objects it defines classes (like Array, Graph or Point), for others STL is used (std::string).

There are two ways of generating objects. The first is with static methods of the class.

auto a = Array::random(n, maxSize);
auto t = Tree::bamboo(n);

Arrays, trees and graphs are generated like this.

The second uses helper objects.

auto polygon = rndg.convexPolygon(n, maxCoordinate);
auto stringPair = rnds.antiHash({{1000000007, 101}, {1000000009, 211}}, "a-z", 10000);
int p = rndm.randomPrime(100, int(1e9));

Strings, geometric primitives, primes and partitions and simply random numbers are generated with such helpers.

For each Jngen object there are operators for printing to streams. There are modifiers which allow, for example, to switch between 0- and 1-indexation. Also Jngen allows printing standard containers like vectors and pairs. See section printers.

cout << std::vector<int>{1, 2, 3} << endl;
cout << Array::id(5).shuffled().printN().add1() << endl;
---
1 2 3
5
5 2 4 3 1

The library also supplies a command-line arguments parser and a tool for drawing geometric primitives.

Jngen is large, its compilation lasts for several seconds. It is possible to make it faster with precompiling a part of it. See this chapter for manual.

If you want to learn more about Jngen, please see all the docs listed at the reference section. Good luck!