149using namespace Aleph;
158 cout <<
"+" << string(70,
'-') <<
"+" <<
endl;
159 cout <<
"| " << left << setw(68) << title <<
" |" <<
endl;
160 cout <<
"+" << string(70,
'-') <<
"+" <<
endl;
197 dept_codes.insert(
"54",
"Norte de Santander");
206 cout <<
"\n Total departments registered: " <<
dept_codes.size() <<
endl;
236 cout <<
" " << left << setw(20) << name <<
" -> Code "
242 cout <<
" Has code '11'? " << (
dept_codes.valid_key(
"11") ?
"Yes" :
"No") <<
endl;
243 cout <<
" Has code '99'? " << (
dept_codes.valid_key(
"99") ?
"Yes" :
"No") <<
endl;
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"
272 coffee_regions.for_each([](
const string& region,
const string& profile) {
273 cout <<
" " << left << setw(12) << region <<
": " << profile <<
endl;
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);
310 cout <<
" " << left << setw(15) <<
city <<
": "
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");
354 cout <<
"\n Indigenous languages registered: " <<
lang_codes.size() <<
endl;
367 for (
size_t i = 0; i <
languages.size(); ++i)
370 cout <<
" " << left << setw(15) <<
lang <<
" -> code: "
382 for (
size_t i = 0; i <
codes.size(); ++i)
395 print_header(
"Example 5: Modifiable Mapping - Exchange Rates");
412 cout <<
" 1 " <<
currency <<
" = " << fixed << setprecision(2)
422 cout <<
" Updated USD: 1 USD = " <<
exchange[
"USD"] <<
" COP" <<
endl;
423 cout <<
" Updated EUR: 1 EUR = " <<
exchange[
"EUR"] <<
" COP" <<
endl;
427 cout <<
" Removing ARS..." <<
endl;
429 cout <<
" Has ARS? " << (
exchange.valid_key(
"ARS") ?
"Yes" :
"No") <<
endl;
430 cout <<
" Total currencies: " <<
exchange.size() <<
endl;
461 cities.insert(
"Medellin", {6.244, -75.574});
462 cities.insert(
"Cali", {3.451, -76.532});
463 cities.insert(
"Barranquilla", {10.964, -74.796});
464 cities.insert(
"Cartagena", {10.391, -75.479});
465 cities.insert(
"Cucuta", {7.893, -72.508});
466 cities.insert(
"Santa Marta", {11.241, -74.199});
467 cities.insert(
"Leticia", {-4.215, -69.940});
468 cities.insert(
"San Andres", {12.584, -81.701});
473 cout <<
" " << left << setw(15) <<
city
474 << fixed << setprecision(3)
475 <<
"(" << setw(8) << c.lat <<
", " << setw(8) << c.lon <<
")" <<
endl;
500 cout <<
" Bogota -> " << left << setw(15) <<
city
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.
AHMapping< ValueType, Key > inverse() const
Creates a new mapping with keys and values swapped.
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 & append()
Allocate a new entry to the end of array.
__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.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::string code(Node *root)
Compute a string with the Lukasiewicz`s word of a tree.
Lazy and scalable dynamic array implementation.