2#ifndef _aspose_system_collections_queue_h_
3#define _aspose_system_collections_queue_h_
5#include "system/object.h"
6#include "system/collections/base_enumerator.h"
7#include "system/collections/ienumerable.h"
8#include "system/collections/icollection.h"
9#include "system/cycles_detection.h"
14namespace Collections {
18template<
typename T>
class Queue;
89 ASPOSE_COLLECTION_POINTER_MODE_CONTROL(T)
101 typedef std::list<T, ASPOSE_COLLECTION_ALLOCATOR_TYPE>
queue_t;
132 Queue() : ASPOSE_COLLECTION_INIT_ALLOCATOR() {}
136 Queue(
int capacity) : ASPOSE_COLLECTION_INIT_ALLOCATOR()
139 throw ArgumentOutOfRangeException(u
"capacity");
149 throw ArgumentNullException(u
"items");
152 auto e = items->GetEnumerator();
153 while (e->MoveNext())
154 m_data.push_back(e->get_Current());
168 return ASPOSECPP_CHECKED_CAST(
int, m_data.size());
181 return std::find(m_data.begin(), m_data.end(), item) != m_data.end();
187 m_data.push_back(item);
196 throw InvalidOperationException(u
"Queue is empty");
198 T rv = m_data.front();
209 throw InvalidOperationException(u
"Queue is empty");
211 return m_data.front();
224 return new System::Details::NativeIteratorWrapper<T, typename queue_t::iterator>(m_data.begin(), m_data.end());
229 return new System::Details::NativeIteratorWrapper<T, typename queue_t::iterator>(m_data.end(), m_data.end());
234 return new System::Details::NativeConstIteratorWrapper<T, typename queue_t::const_iterator>(m_data.begin(), m_data.end());
239 return new System::Details::NativeConstIteratorWrapper<T, typename queue_t::const_iterator>(m_data.end(), m_data.end());
246#ifdef __DBG_FOR_EACH_MEMBER
250 void DBG_for_each_member(DBG::for_each_member_visitor &visitor)
const override
252 visitor.add_self(
this);
253 DBG::for_each_of_Object(
this, m_data, visitor);
258 const char* DBG_class_name()
const override {
return "Queue<T>"; }
262#ifdef ASPOSE_GET_SHARED_MEMBERS
264 DEFINE_GET_SHARED_MEMBERS(m_data)
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:25
Enumerator to iterate through queue. Objects of this class should only be allocated using System::Mak...
Definition: queue.h:122
RTTI_INFO_TEMPLATE_CLASS(Queue< T >::Enumerator, System::BaseTypesInfo< System::Object >)
RTTI information.
Enumerator(const ThisPtr &data)
Constructs enumerator pointing to specific queue.
Definition: queue.h:126
Queue class forward declaration.
Definition: queue.h:88
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginConstIterator() const override
Gets the implementation of begin const iterator for the current container.
Definition: queue.h:232
Queue()
Constructs empty queue.
Definition: queue.h:132
System::Details::VirtualizedIteratorBase< T > * virtualizeBeginIterator() override
Gets the implementation of begin iterator for the current container.
Definition: queue.h:222
IEnumeratorPtr GetEnumerator() override
Gets enumerator to iterate through the queue.
Definition: queue.h:159
std::list< T, ASPOSE_COLLECTION_ALLOCATOR_TYPE > queue_t
Underlying data type.
Definition: queue.h:101
T Dequeue()
Gets item from the beginning of the queue.
Definition: queue.h:192
queue_t m_data
Wrapped data structure.
Definition: queue.h:109
System::Details::VirtualizedIteratorBase< T > * virtualizeEndConstIterator() const override
Gets the implementation of end const iterator for the current container.
Definition: queue.h:237
void Enqueue(const T &item)
Puts item to the end of the queue.
Definition: queue.h:185
virtual void Clear()
Deletes all elements in queue.
Definition: queue.h:171
SharedPtr< IEnumerable< T > > IEnumerablePtr
Container of same type elements.
Definition: queue.h:113
System::Details::VirtualizedIteratorBase< T > * virtualizeEndIterator() override
Gets the implementation of end iterator for the current container.
Definition: queue.h:227
queue_t & data()
Underlying data structure accessor.
Definition: queue.h:216
SharedPtr< IEnumerator< T > > IEnumeratorPtr
Enumerator type.
Definition: queue.h:115
T Peek()
Gets item from the beginning of the queue, but does not remove it from queue.
Definition: queue.h:205
SharedPtr< Queue< T > > ThisPtr
Pointer type.
Definition: queue.h:105
~Queue() override
Destructor.
Definition: queue.h:244
virtual int get_Count() const
Gets number of elements in queue.
Definition: queue.h:166
Queue(const SharedPtr< IEnumerable< T > > &items)
Copy constructor.
Definition: queue.h:145
T ValueType
This type.
Definition: queue.h:93
queue_t::iterator queueIt_t
Iterator type.
Definition: queue.h:107
const queue_t & data() const
Underlying data structure accessor.
Definition: queue.h:219
virtual bool Contains(const T &item) const
Checks if queue contains specific element using operator == to compare elements.
Definition: queue.h:179
Queue(int capacity)
Constructs empty queue.
Definition: queue.h:136
Queue pointer. This type is a pointer to manage other object's deletion. It should be allocated on st...
Definition: queue.h:26
QueuePtr()
Constructs null pointer.
Definition: queue.h:29
QueuePtr(const SharedPtr< Queue< T > > &obj)
Constructs pointer to specific queue.
Definition: queue.h:32
Iterator class for simple containers holding elements directly using rbegin() and rend() functions....
Definition: base_enumerator.h:81
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1650