xtd 0.2.0
Loading...
Searching...
No Matches
array_list.cpp

Shows how to use array_list alias.

#include <xtd/collections/array_list>
#include <xtd/console>
using namespace xtd;
using namespace xtd::collections;
template<typename collection_t>
void print_values(const collection_t& my_list) {
for (auto obj : my_list)
console::write(" {0}", obj);
console::write_line();
}
auto main() -> int {
// Creates and initializes a new vector_list.
auto my_vl = array_list {};
my_vl.emplace_back("Hello");
my_vl.emplace_back("World");
my_vl.emplace_back("!");
// Displays the properties and values of the vector_list.
console::write_line("my_vl");
console::write_line(" size: {0}", my_vl.size());
console::write_line(" Capacity: {0}", my_vl.capacity());
console::write(" Values:");
print_values(my_vl);
}
// This code produces the following output :
//
// my_vl
// size: 3
// Capacity: 4
// Values: Hello World !
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:71
reference emplace_back(args_t &&... args)
Appends a new element to the end of the container. The element is constructed through std::allocator_...
Definition list.hpp:530
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10