42 template<
class type_t,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_t>>
43 class queue :
public xtd::object,
public xtd::collections::generic::icollection<type_t> {
49 using value_type =
typename icollection<type_t>::value_type;
75 data_->items.add(
queue.pop());
81 struct std_queue :
public std::queue<type_t> {
82 std_queue(
const std::queue<type_t>&
queue) :
ptr {
reinterpret_cast<const std_queue*
>(&
queue)} {}
83 auto begin()
const {
return ptr->c.begin();}
84 auto end()
const {
return ptr->c.end();}
104 queue(std::initializer_list<type_t> il) {
111 template < std::input_iterator input_iterator_t >
113 for (
auto iterator =
first; iterator !=
last; ++iterator)
128 [[nodiscard]]
auto count() const noexcept ->
size_type override {
return data_->items.count();}
132 std::queue<type_t>
items()
const {
return std::queue<type_t>(std::deque<type_t>(data_->items.begin(), data_->items.end()));}
143 data_->items.clear();
150 return data_->items.contains(value);
161 data_->items.copy_to(
array, array_index);
176 data_->items.add_last(value);
185 return data_->capacity;
191 return data_->items.get_enumerator();
214 auto to_string() const noexcept ->
string override {
return data_->items.to_string();}
236 if (!
try_peek(result))
return false;
237 data_->items.remove_first();
245 result =
count() ? data_->items.first()->value() : type_t {};
255 operator std::queue<type_t>()
const {
return items();}
259 auto is_read_only() const noexcept ->
bool override {
return false;}
260 auto is_synchronized() const noexcept ->
bool override {
return false;}
262 auto add(
const type_t& value) ->
void override {
enqueue(value);}
263 auto remove(
const type_t&) ->
bool override {
return false;}
276 template <
class type_t,
class allocator_t = xtd::collections::
generic::helpers::allocator < type_t>>
279 template <
class type_t,
class allocator_t = xtd::collections::
generic::helpers::allocator < type_t>>
282 template <
class type_t>
285 template <
class type_t>
286 queue(std::initializer_list < type_t >) -> queue < type_t >;
288 template <
class input_iterator_t>
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Represents a doubly linked list.
Definition linked_list.hpp:51
Represents a first-in, first-out collection of objects.
Definition queue.hpp:43
auto trim_excess() -> void
Sets the capacity to the actual number of elements in the xtd::collections::generic::queue <type_t>,...
Definition queue.hpp:220
auto peek() const -> value_type
Returns the object at the beginning of the xtd::collections::generic::queue <type_t> without removing...
Definition queue.hpp:198
queue(const queue &queue)=default
Default copy constructor with specified queue.
auto trim_excess(size_type capacity) -> void
Sets the capacity of a xtd::collections::generic::queue <type_t> object to the specified number of en...
Definition queue.hpp:227
queue(queue &&queue)=default
Move constructor with specified queue.
queue()=default
Initializes a new instance of the xtd::collections::generic::queue <type_t> class that is empty and h...
auto try_dequeue(value_type &result) noexcept -> bool
Removes the object at the beginning of the xtd::collections::generic::queue <type_t>,...
Definition queue.hpp:235
auto dequeue() -> value_type
Removes and returns the object at the beginning of the xtd::collections::generic::queue <type_t>.
Definition queue.hpp:167
auto capacity() const noexcept -> size_type
Definition queue.hpp:124
const value_type & const_reference
Represents the const reference of list value type.
Definition queue.hpp:57
queue(size_type capacity)
Initializes a new instance of the xtd::collections::generic::queue <type_t> class that is empty and h...
Definition queue.hpp:99
queue(const std::queue< type_t > &queue)
Default copy constructor with specified queue.
Definition queue.hpp:80
auto try_peek(value_type &result) const noexcept -> bool
Returns a value that indicates whether there is an object at the beginning of the xtd::collections::g...
Definition queue.hpp:244
xtd::collections::generic::linked_list< value_type, allocator_t > base_type
Represents the list base type.
Definition queue.hpp:51
auto ensure_capacity(size_type capacity) -> size_type
Ensures that the capacity of this queue is at least the specified capacity. If the current capacity i...
Definition queue.hpp:183
auto to_string() const noexcept -> string override
Returns a xtd::string that represents the current object.
Definition queue.hpp:214
queue(std::queue< type_t > &&queue)
Move constructor with specified queue.
Definition queue.hpp:73
queue(input_iterator_t first, input_iterator_t last)
Constructs the container with the contents of the range [first, last).
Definition queue.hpp:112
std::queue< xtd::any_object > items() const
Definition queue.hpp:132
auto contains(const_reference value) const noexcept -> bool override
Determines whether an element is in the xtd::collections::generic::queue <type_t>.
Definition queue.hpp:149
auto enqueue(const_reference value) -> void
Adds an object to the end of the xtd::collections::generic::queue <type_t>.
Definition queue.hpp:175
auto clear() -> void override
Removes all elements from the xtd::collections::generic::queue <type_t>.
Definition queue.hpp:142
auto copy_to(xtd::array< type_t > &array, size_type array_index) const -> void override
Copies the entire xtd::colllections::generic::linked_list <type_t> to a compatible one-dimensional ar...
Definition queue.hpp:160
queue(const ienumerable< value_type > &collection)
Initializes a new instance of the xtd::collections::generic::queue <type_t> class that contains eleme...
Definition queue.hpp:93
queue(std::initializer_list< type_t > il)
Constructs the container with the contents of the specified initializer list, and allocator.
Definition queue.hpp:104
value_type & reference
Represents the reference of list value type.
Definition queue.hpp:55
auto to_array() const -> xtd::array< value_type >
Copies the xtd::collections::generic::queue <type_t> elements to a new array.
Definition queue.hpp:206
typename icollection< type_t >::value_type value_type
Represents the list value type.
Definition queue.hpp:49
enumerator< value_type > get_enumerator() const noexcept override
Returns an enumerator that iterates through the xtd::collections::generic::queue <type_t>.
Definition queue.hpp:190
auto count() const noexcept -> size_type override
Gets the number of nodes actually contained in the xtd::collections::generic::queue <type_t>.
Definition queue.hpp:128
xtd::size size_type
Represents the list size type (usually xtd::size).
Definition queue.hpp:53
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
generic::queue< xtd::any_object > queue
Represents a first-in, first-out collection of objects.
Definition queue.hpp:27
generic::ienumerable< xtd::any_object > ienumerable
Exposes an enumerator, which supports a simple iteration over a non-generic collection.
Definition ienumerable.hpp:32
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
type_t as(any_object &o)
Casts a type into another type.
Definition __as_any_object.hpp:59
@ add
The Add key.
Definition console_key.hpp:170
Contains xtd::collections::generic::linked_list <type_t> class.
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
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
const_iterator begin() const
Returns an iterator to the beginning.
Definition read_only_span.hpp:183
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
const_iterator end() const
Returns an iterator to the end.
Definition read_only_span.hpp:213
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
Contains xtd::collections::generic::helpers::raw_array class.
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:38