xtd 0.2.0
Loading...
Searching...
No Matches

◆ array_list

Represents a collection of std::any.

Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:71
Header
#include <xtd/collections/array_list>
Namespace
xtd::collections
Library
xtd.core
Examples
The following example shows hows to use xtd::collections::array_list.
#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);
}
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(" 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 !
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.h:534
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.h:462
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Represents the standard input, output, and error streams for console applications.
Definition console.h:36
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Remarks
TTo add a class, structure or any other type unknown to xtd, you need to implement the xtd::iequatable and xtd::icompoabale interfaces or overrride the == and < operetors.