167using namespace Aleph;
176 cout <<
"+" << string(70,
'-') <<
"+" <<
endl;
178 cout <<
"+" << string(70,
'-') <<
"+" <<
endl;
187template <
typename Container>
190 cout <<
" " << name <<
" (" << c.size() <<
" elements): ";
191 for (
const auto& item : c)
199 cout <<
" " << name <<
" (" <<
l.
size() <<
" elements): ";
200 for (
auto it =
l.
get_it(); it.has_curr(); it.next_ne())
201 cout << it.get_curr() <<
" ";
208 cout <<
" " << name <<
" (" << arr.
size() <<
" elements): ";
209 for (
size_t i = 0; i < arr.
size(); ++i)
210 cout << arr(i) <<
" ";
220 print_header(
"Example 1: std::vector <-> DynList Conversions");
224 "Bogota",
"Medellin",
"Cali",
"Barranquilla",
"Cartagena"
236 cout <<
" (vector_to_DynList also works)" <<
endl;
251 vector<int> population = {8281, 2569, 2228, 1274, 1047};
259 cout <<
" Total population: " <<
total <<
" thousand" <<
endl;
268 print_header(
"Example 2: std::vector <-> DynArray Conversions");
271 vector<double>
areas = {63612, 23188, 22140, 44640, 25020, 24885};
292 cout <<
"\n Statistics (using STL algorithms):" <<
endl;
294 cout <<
" Average: " << avg <<
" km2" <<
endl;
303 print_header(
"Example 3: std::list <-> DynList Conversions");
307 "Magdalena",
"Cauca",
"Atrato",
"Meta",
"Guaviare",
"Caqueta"
331 cout <<
" (Note: set maintains sorted order)" <<
endl;
343 vector<double>
temps = {23.5, 25.1, 24.8, 26.2, 22.9, 27.0, 25.5, 24.0};
363 int days[] = {1, 2, 3, 4, 5, 6, 7};
381 cout <<
" Tuple elements: ";
393 string(
"Cauca"),
string(
"Tolima"));
395 cout <<
" Tuple elements: ";
404 cout << it.get_curr() <<
" ";
411 cout <<
" Processing heterogeneous tuple:" <<
endl;
438 "Cafe",
"Flores",
"Banano",
"Carbon",
"Petroleo"
446 "Leticia",
"Mitú",
"Puerto Inírida",
"San José del Guaviare"
449 cout <<
" Amazon region cities:" <<
endl;
450 for (
auto it =
cities.
get_it(); it.has_curr(); it.next_ne())
451 cout <<
" - " << it.get_curr() <<
endl;
465 vector<double>
gdp = {6500, 8200, 7800, 5900, 12000};
471 cout <<
" GDP per capita (COP): ";
480 return "$" +
to_string(
static_cast<int>(val)) +
" USD";
486 vector<int>
quantities = {10, 25, 15, 30, 20};
504 print_header(
"Example 8: Integration - Processing Pipeline");
506 cout <<
"\n Scenario: Process sales data from STL to Aleph-w and back\n" <<
endl;
511 {
"Medellin", 890000},
513 {
"Barranquilla", 450000},
514 {
"Cartagena", 380000}
517 cout <<
" Step 1: Original STL data (city, sales)" <<
endl;
534 cout <<
"\n Step 2: Converted to Aleph-w DynList" <<
endl;
549 cout <<
"\n Step 3: Aleph-w processing" <<
endl;
551 cout <<
" Average: " << avg <<
" COP" <<
endl;
557 cout <<
"\n Step 4: Back to STL for output" <<
endl;
558 cout <<
" Sales above average: ";
571 cout <<
"========================================================================" <<
endl;
572 cout <<
" ALEPH-W STL UTILS EXAMPLE" <<
endl;
573 cout <<
" STL <-> Aleph-w Container Conversions" <<
endl;
574 cout <<
"========================================================================" <<
endl;
586 cout <<
"========================================================================" <<
endl;
587 cout <<
" Example completed successfully!" <<
endl;
588 cout <<
"========================================================================" <<
endl;
Conversion utilities between Aleph-w containers and STL containers.
Simple dynamic array with automatic resizing and functional operations.
size_t size() const noexcept
Return the current dimension of array.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Append a new item by copy.
size_t size() const noexcept
Count the number of elements of the list.
__T foldl(const __T &init, Op &op) const
Fold the elements of the container to a specific result.
Aleph::DynList< T > filter(Operation &operation) const
Filter the elements of a container according to a matching criteria.
size_t length() const noexcept
Count the number of elements of a container.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
Array< T > tuple_to_array(const std::tuple< T, U... > &t)
Convert a tuple to an Array.
auto range_to_DynList(Iterator begin, Iterator end) -> DynList< std::decay_t< decltype(*begin)> >
Convert an iterator range to a DynList.
DynList< T > to_DynList(const Array< T > &a)
Convert an Array to a DynList.
DynList< T > list_to_DynList(const std::list< T > &l)
Convert a std::list to a DynList.
T accumulate(Itor beg, Itor end, T initValue)
Accumulate values in a range.
DynList< T > vector_to_DynList(const std::vector< T > &v)
Convert a std::vector to a DynList.
DynList< T > tuple_to_dynlist(const std::tuple< T, U... > &t)
Convert a tuple to a DynList.
auto stl_container_to_dynList(const StlContainer &container) -> DynList< typename StlContainer::value_type >
Convert any STL container to a DynList.
std::string to_string(const time_t t, const std::string &format)
Format a time_t value into a string using format.
DynArray< T > vector_to_DynArray(const std::vector< T > &v)
Convert a std::vector to a DynArray.
std::vector< T > DynArray_to_vector(const DynArray< T > &arr)
Convert a DynArray to a std::vector.
std::list< T > DynList_to_list(const DynList< T > &l)
Convert a DynList to a std::list.
void tuple_for_each(const std::tuple< Ts... > &tuple, F func, std::index_sequence< Is... >)
Apply a function to each element in a tuple (tuple first).
std::vector< typename C::Item_Type > to_vector(const C &c)
Convert a container to a std::vector.
DynList< T > maps(const C &c, Op op)
Classic map operation.
auto map_vector(const std::vector< T > &v, Op op) -> std::vector< std::decay_t< decltype(op(v[0]))> >
Map a function over a std::vector.
void demo_vector_dynlist()
void demo_range_conversions()
void print_dynlist(const string &name, const DynList< T > &l)
void demo_variadic_packing()
void print_dynarray(const string &name, const DynArray< T > &arr)
void demo_tuple_conversions()
void demo_map_transformations()
void print_subheader(const string &subtitle)
void demo_vector_dynarray()
void print_stl_container(const string &name, const Container &c)
Lazy and scalable dynamic array implementation.