template<typename type_t, typename container_t = std::deque<type_t>>
class xtd::collections::generic::queue< type_t, container_t >
Represents a first-in, first-out collection of objects.
- Definition
template<typename type_t, typename container_t = std::deque<type_t>>
Defines methods to manipulate generic collections.
Definition icollection.hpp:45
queue()=default
Initializes a new instance of the xtd::collections::generic::queue <type_t> class that is empty and h...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
- Header
#include <xtd/collections/generic/queue>
- Namespace
- xtd::collections::generic
- Library
- xtd.core
- Template Parameters
-
- Examples
- The following code example demonstrates several methods of the xtd::collections::generic::queue <type_t> generic class. The code example creates a queue of strings with default capacity and uses the xtd::collections::generic::queue::enqueue method to queue five strings. The elements of the queue are enumerated, which does not change the state of the queue. The xtd::collections::generic::queue::dequeue method is used to dequeue the first string. The xtd::collections::generic::queue::peek method is used to look at the next item in the queue, and then the xtd::collections::generic::queue::dequeue method is used to dequeue it. The xtd::collections::generic::queue::to_array method is used to create an array and copy the queue elements to it, then the array is passed to the xtd::collections::generic::queue <type_t> constructor that takes xtd::collections::generic::ienumerable <type_t>, creating a copy of the queue. The elements of the copy are displayed. An array twice the size of the queue is created, and the xtd::collections::generic::queue::copy_to method is used to copy the array elements beginning at the middle of the array. The xtd::collections::generic::queue <type_t> constructor is used again to create a second copy of the queue containing three null elements at the beginning. The xtd::collections::generic::queue::contains method is used to show that the string "four" is in the first copy of the queue, after which the Clear method clears the copy and the xtd::collections::generic::queue::count property shows that the queue is empty.
#include <xtd/xtd>
namespace examples {
class program {
public:
static void main() {
numbers.enqueue("one");
numbers.enqueue("two");
numbers.enqueue("three");
numbers.enqueue("four");
numbers.enqueue("five");
for(
auto number : queue_copy )
numbers.copy_to(array2, numbers.count());
for(
auto number : queue_copy2 )
queue_copy.clear();
}
};
}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents a first-in, first-out collection of objects.
Definition queue.hpp:47
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:284
|
| | queue ()=default |
| | Initializes a new instance of the xtd::collections::generic::queue <type_t> class that is empty and has the default initial capacity.
|
| | queue (queue &&queue) |
| | Move constructor with specified queue.
|
| | queue (const queue &queue)=default |
| | Default copy constructor with specified queue.
|
| | queue (std::queue< type_t > &&queue) |
| | Move constructor with specified queue.
|
| | queue (const std::queue< type_t > &queue) |
| | Default copy constructor with specified queue.
|
| | queue (const ienumerable< value_type > &collection) |
| | Initializes a new instance of the xtd::collections::generic::queue <type_t> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
|
| | queue (size_type capacity) |
| | Initializes a new instance of the xtd::collections::generic::queue <type_t> class that is empty and has the specified initial capacity.
|
| | queue (std::initializer_list< type_t > il) |
| | Constructs the container with the contents of the specified initializer list, and allocator.
|
| template<std::input_iterator input_iterator_t> |
| | queue (input_iterator_t first, input_iterator_t last) |
| | Constructs the container with the contents of the range [first, last).
|
|
| using | value_type |
| | Represents the xtd::collections::generic::icollection value type.
|
| using | value_type |
| | Represents the xtd::collections::generic::ienumerable value type.
|
| using | iterator |
| | Represents the iterator of xtd::collections::generic::ienumerable value type.
|
| using | const_iterator |
| | Represents the const iterator of xtd::collections::generic::ienumerable value type.
|
| using | iterator |
| | Represents the iterator of enumerable value type.
|
| using | const_iterator |
| | Represents the const iterator of enumerable value type.
|
| using | enumerable_type |
| | Represents the ienumerable enumerable type.
|
| using | source_type |
| | Represents the ienumerable source type.
|
| using | ienumerable |
| | Represents the ienumerable value type.
|
| using | list |
| | Represents the list value type.
|
| | object ()=default |
| | Create a new instance of the ultimate base class object.
|
| virtual auto | equals (const object &obj) const noexcept -> bool |
| | Determines whether the specified object is equal to the current object.
|
| virtual auto | get_hash_code () const noexcept -> xtd::usize |
| | Serves as a hash function for a particular type.
|
| virtual auto | get_type () const noexcept -> type_object |
| | Gets the type of the current instance.
|
| template<typename object_t> |
| auto | memberwise_clone () const -> xtd::unique_ptr_object< object_t > |
| | Creates a shallow copy of the current object.
|
| virtual auto | contains (const type_t &item) const noexcept -> bool=0 |
| | Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value.
|
| virtual auto | begin () const -> const_iterator |
| | Returns an iterator to the first element of the enumerable.
|
| virtual auto | cbegin () const -> const_iterator |
| | Returns an iterator to the first element of the enumerable.
|
| virtual auto | cend () const -> const_iterator |
| | Returns an iterator to the element following the last element of the enumerable.
|
| virtual auto | end () const -> const_iterator |
| | Returns an iterator to the element following the last element of the enumerable.
|
| auto | aggregate (const std::function< type_t(const type_t &, const type_t &)> &funcfunc) const -> type_t |
| | Applies an accumulator function over a sequence.
|
| auto | all (const std::function< bool(const type_t &)> &predicatepredicate) const -> bool |
| | Determines whether all elements of a sequence satisfy a condition.
|
| auto | any () const noexcept -> bool |
| | Determines whether a sequence contains any elements.
|
| auto | append (const type_t &element) const noexcept |
| | Appends a value to the end of the sequence.
|
| auto | as_enumerable () const noexcept |
| | Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
|
| auto | average () const noexcept |
| | Computes the average of a sequence of source_t values.
|
| auto | cast () const noexcept |
| | Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
|
| auto | chunk (xtd::usize size) const |
| | Splits the elements of a sequence into chunks of size at most size.
|
| auto | concat (const ienumerable< type_t > &second) const noexcept |
| | Concatenates two sequences.
|
| auto | contains (const type_t &value) const noexcept -> bool |
| | Determines whether a sequence contains a specified element by using the default equality comparer.
|
| auto | count () const noexcept -> xtd::usize |
| | Returns the number of elements in current sequence.
|
| auto | count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept |
| | Returns the count of elements in the current sequence grouped by key.
|
| auto | default_if_empty () const noexcept |
| | Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
|
| auto | distinct () const noexcept |
| | Returns distinct elements from a sequence by using the default equality comparer to compare values.
|
| auto | first_or_default (const std::function< bool(const type_t &)> &predicatepredicate, const type_t &default_value) const noexcept -> type_t |
| | Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
|
| auto | order () const |
| | Sorts the elements of a sequence in ascending order.
|
| auto | order_by (const std::function< type_t(const type_t &)> &key_selector) const |
| | Sorts the elements of a sequence in ascending order according to a key.
|
| auto | order_by_descending (const std::function< key_t(const type_t &)> &key_selector) const |
| | Sorts the elements of a sequence in descending order according to a key.
|
| auto | select (auto &&selector) const |
| | Projects each element of a sequence into a new form.
|
| auto | to_array () const noexcept -> xtd::array< type_t > |
| | Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | to_list () const noexcept -> xtd::collections::generic::list< type_t > |
| | Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | where (auto &&predicatepredicate) const |
| | Filters a sequence of values based on a predicate.
|
| virtual auto | empty () const noexcept -> bool |
| | Checks whether the container is empty.
|
| virtual auto | size () const noexcept -> xtd::usize |
| | Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
|
| virtual auto | operator<< (const type_t &item) -> icollection< type_t > & |
| | The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>.
|
| virtual auto | operator>> (const type_t &item) -> icollection< type_t > & |
| | The shift right operator removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are considered equal.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are the same instance.
|
| static auto | to_const_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator |
| | Converts source iterator to target iterator.
|
| static auto | to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator |
| | Converts source iterator to target iterator.
|