149using namespace Aleph;
158 cout <<
"+" << string(70,
'-') <<
"+" <<
endl;
160 cout <<
"+" << string(70,
'-') <<
"+" <<
endl;
236 cout <<
" " << left <<
setw(20) << name <<
" -> Code "
252 print_header(
"Example 2: Variadic Constructor - Coffee Regions");
256 "Huila",
"Sur del pais, cafe con notas citricos",
257 "Narino",
"Alta montania, cafe suave y frutal",
258 "Cauca",
"Region volcanica, cafe de acidez brillante",
259 "Tolima",
"Clima templado, cafe balanceado",
260 "Antioquia",
"Tradicion cafetera, cafe con cuerpo",
261 "Caldas",
"Eje Cafetero, cafe clasico colombiano",
262 "Quindio",
"Paisaje Cultural Cafetero, cafe aromatico",
263 "Risaralda",
"Eje Cafetero, cafe de montania",
264 "Santander",
"Oriente, cafe organico y especial"
278 cout <<
"\n All regions: ";
280 for (
auto it = keys.get_it(); it.has_curr(); it.next_ne())
281 cout << it.get_curr() <<
" ";
291 print_header(
"Example 3: Numeric Mappings - City Population");
296 population.
insert(
"Bogota", 8281);
297 population.
insert(
"Medellin", 2569);
298 population.
insert(
"Cali", 2228);
299 population.
insert(
"Barranquilla", 1274);
300 population.
insert(
"Cartagena", 1047);
301 population.
insert(
"Cucuta", 711);
302 population.
insert(
"Bucaramanga", 609);
303 population.
insert(
"Pereira", 488);
304 population.
insert(
"Santa Marta", 538);
305 population.
insert(
"Ibague", 580);
311 << right <<
setw(6) << pop <<
" mil habitantes" <<
endl;
317 auto values = population.
values();
318 for (
auto it = values.get_it(); it.has_curr(); it.next_ne())
319 total += it.get_curr();
321 cout <<
" Sum of registered cities: " <<
total <<
" mil habitantes" <<
endl;
322 cout <<
" (Approx. " <<
total / 1000.0 <<
" millones)" <<
endl;
326 cout <<
" Contains city with 2569k? "
328 cout <<
" Contains city with 5000k? "
338 print_header(
"Example 4: Encoding/Decoding - Language Codes");
382 for (
size_t i = 0; i <
codes.
size(); ++i)
395 print_header(
"Example 5: Modifiable Mapping - Exchange Rates");
475 <<
"(" <<
setw(8) << c.lat <<
", " <<
setw(8) << c.lon <<
")" <<
endl;
512 cout <<
"========================================================================" <<
endl;
513 cout <<
" ALEPH-W MAPPING EXAMPLE" <<
endl;
514 cout <<
" Bidirectional Key-Value Mappings" <<
endl;
515 cout <<
"========================================================================" <<
endl;
525 cout <<
"========================================================================" <<
endl;
526 cout <<
" Example completed successfully!" <<
endl;
527 cout <<
"========================================================================" <<
endl;
Bidirectional mapping between two types.
A generic key-value mapping container with inverse operation support.
DynList< ValueType > values() const
Gets all values in the mapping.
bool contains_value(const ValueType &value) const
Checks if the mapping contains a specific value.
void insert(const Key &key, const ValueType &value)
Inserts or updates a key-value pair in the mapping.
void for_each(F f) const
Applies a function to each key-value pair.
T & insert(const T &item)
Insert a new item by copy.
T & append(const T &item)
Append a new item by copy.
T remove()
Remove the first item of the list.
size_t size() const noexcept
Count the number of elements of the list.
size_t length() const noexcept
Count the number of elements of a container.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_cos_function > > cos(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sqrt_function > > sqrt(const __gmp_expr< T, U > &expr)
void demo_city_coordinates()
void demo_variadic_constructor()
void demo_department_codes()
void print_subheader(const string &subtitle)
void demo_encoding_decoding()
void demo_modifiable_mapping()
void demo_numeric_mapping()
Main namespace for Aleph-w library functions.
std::string code(Node *root)
Compute a string with the Lukasiewicz`s word of a tree.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Aleph::DynList< T > keys() const
Lazy and scalable dynamic array implementation.