xtd 0.2.0
xtd::collections Namespace Reference

Definition

The xtd::collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries.

Namespaces

namespace  generic
 The xtd::collections::generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections.
 
namespace  object_model
 Contains classes that can be used as collections in the object model of a reusable library. Use these classes when properties or methods return collections.
 
namespace  specialized
 The xtd::collections::specialized namespace contains specialized and strongly-typed collections; for example, a linked list dictionary, a bit vector, and collections that contain only strings.
 

Classes

class  bit_array
 Manages a compact array of bit values, which are represented as booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0). More...
 
class  key_not_found_exception
 The exception that is thrown when the key specified for accessing an element in a collection does not match any key in the collection. More...
 

Alias

using array_list
 Represents a collection of xtd::any_object.
 
using comparer
 Exposes a method that compares two objects.
 
using dictionary_entry
 Defines a dictionary key/value pair that can be set or retrieved.
 
using enumerator
 Supports a simple iteration over a non-generic collection.
 
using hashtable
 Represents a collection of key/value pairs that are organized based on the hash code of the key.
 
using icollection
 Defines size, enumerators, and synchronization methods for all nongeneric collections.
 
using icomparer
 interface IComparer exposes a method that compares two objects.
 
using idictionary
 interface IComparer exposes a method that compares two objects.
 
using ienumerable
 Exposes an enumerator, which supports a simple iteration over a non-generic collection.
 
using ienumerator
 Supports a simple iteration over a non-generic collection.
 
using iequality_comparer
 Defines methods to support the comparison of objects for equality.
 
using ilist
 Represents a non-generic collection of objects that can be individually accessed by index.
 
using queue
 Represents a first-in, first-out collection of objects.
 
using sorted_list
 Represents a collection of xtd::any_object.
 
using stack
 Represents a collection of xtd::any_object.
 
using dictionary_entry
 Defines a dictionary key/value pair that can be set or retrieved.
 
using array_list
 Represents a collection of xtd::any_object.
 

Typedef Documentation

◆ dictionary_entry

Defines a dictionary key/value pair that can be set or retrieved.

xtd::collections::generic::key_value_pair< xtd::any_object, xtd::any_object > dictionary_entry
Defines a dictionary key/value pair that can be set or retrieved.
Definition dictionary_entry.hpp:26
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:37
Header
#include <xtd/collections/dictionary_entry>
Namespace
xtd::collections
Library
xtd.core

◆ array_list

Represents a collection of xtd::any_object.

Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
generic::list< xtd::any_object > array_list
Represents a collection of xtd::any_object.
Definition array_list.hpp:31
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 !
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:462
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
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.