mn_biqueue.hpp
Go to the documentation of this file.
1 
18 #ifndef _MINILIB_a7a12e6f_55af_455f_8086_826c7dc83357_H_
19 #define _MINILIB_a7a12e6f_55af_455f_8086_826c7dc83357_H_
20 
21 #include "../mn_config.hpp"
22 #include "../queue/mn_binaryqueue.hpp"
23 #include "../mn_algorithm.hpp"
24 
25 namespace mn {
26  namespace container {
27  template<class T>
29  public:
31  using value_type = T;
32  using pointer = value_type*;
36 
38  using iterator_category = TCategory ;
40  using value_type = T;
44  using pointer = value_type*;
46  using reference = value_type& ;
47 
48  explicit basic_binary_queue_iterator(T* pValue)
49  : m_pValue(pValue) { }
50 
51  template<class U>
53  : m_pValue(rhs.m_pValue) { }
54 
55  pointer get() const { return m_pValue; }
56 
57  reference operator*() const { return *m_pValue; }
58  pointer operator->() const { return m_pValue; }
59 
60  bool operator == (const self_type& rhs) const {
61  return rhs.m_pValue == m_pValue; }
62 
63  bool operator != (const self_type& rhs) const {
64  return !(rhs == *this); }
65  private:
67  };
76  template<class T, mn::size_t TITEMSIZE = sizeof(T) >
78  public:
80  using value_type = T;
81  using pointer = T*;
82  using reference = T&;
83  using const_reference = const T&;
86  using const_iterator = const iterator;
87 
88 
90  : m_BinQueue(TITEMSIZE) { m_BinQueue.create(); }
91 
93  : m_BinQueue(other.m_BinQueue) { }
94 
96 
103  }
110  }
111 
118  }
123  const_iterator end() const {
125  }
126 
128  assert(!empty()); return *intern_get(); }
129 
131  assert(!empty()); return *intern_get(); }
132 
133 
138  void push(reference _Element) {
139  if( m_queue.enqueue(&_Element) == ERR_QUEUE_OK) {
140  m_pEnd = &_Element;
141  }
142  }
147  inline pointer pop() {
148  pointer tmp = NULL;
149  m_queue.dequeue(tmp);
150 
151  return tmp;
152  }
153 
157  inline void clear() {
158  m_queue.clear();
159  }
165  inline const bool empty() const {
166  return m_queue.is_empty();
167  }
168 
169  void swap(const self_type& other) {
170  self_type _temp(this);
171  other = this;
172  this = _temp;
173  }
174 
175  self_type& operator = (const self_type& other) {
176  m_BinQueue = other.m_BinQueue:
177  return *this;
178  }
179  private:
181  pointer _pItem;
182  m_queue.peek(_pItem, MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT);
183  return _pItem;
184  }
185  private:
187  };
188 
189  template<class T, mn::size_t TITEMSIZE>
192  a.swap(b);
193  }
194 
195  template<class T, mn::size_t TITEMSIZE = sizeof(T)>
197  }
198 }
199 
200 #endif
Definition: mn_biqueue.hpp:28
pointer operator->() const
Definition: mn_biqueue.hpp:58
basic_binary_queue_iterator(const basic_binary_queue_iterator< U > &rhs)
Definition: mn_biqueue.hpp:52
pointer get() const
Definition: mn_biqueue.hpp:55
ptrdiff_t difference_type
Definition: mn_biqueue.hpp:35
value_type & reference
Definition: mn_biqueue.hpp:33
basic_binary_queue_iterator(T *pValue)
Definition: mn_biqueue.hpp:48
bool operator==(const self_type &rhs) const
Definition: mn_biqueue.hpp:60
value_type * pointer
Definition: mn_biqueue.hpp:32
bool operator!=(const self_type &rhs) const
Definition: mn_biqueue.hpp:63
pointer m_pValue
Definition: mn_biqueue.hpp:66
T value_type
Definition: mn_biqueue.hpp:31
reference operator*() const
Definition: mn_biqueue.hpp:57
This queue can only hold one item. If sucessive push operations are called, that item is overwritten ...
Definition: mn_biqueue.hpp:77
self_type & operator=(const self_type &other)
Definition: mn_biqueue.hpp:175
const bool empty() const
Check, if queue is empty.
Definition: mn_biqueue.hpp:165
void swap(const self_type &other)
Definition: mn_biqueue.hpp:169
iterator begin()
Get the begin iterator.
Definition: mn_biqueue.hpp:101
iterator end()
Get the end iterator.
Definition: mn_biqueue.hpp:108
T * pointer
Definition: mn_biqueue.hpp:81
void clear()
Clear the queue.
Definition: mn_biqueue.hpp:157
pointer pop()
Pop the oldest entry from the queue.
Definition: mn_biqueue.hpp:147
basic_binary_queue_iterator< T > iterator
Definition: mn_biqueue.hpp:85
const T & const_reference
Definition: mn_biqueue.hpp:83
basic_binary_queue()
Definition: mn_biqueue.hpp:89
const_iterator end() const
Get the end iterator.
Definition: mn_biqueue.hpp:123
const_reference item() const
Definition: mn_biqueue.hpp:127
T value_type
Definition: mn_biqueue.hpp:80
T * intern_get()
Definition: mn_biqueue.hpp:180
basic_binary_queue(const self_type &other)
Definition: mn_biqueue.hpp:92
queue_type m_BinQueue
Definition: mn_biqueue.hpp:186
void push(reference _Element)
Push a element to the queue.
Definition: mn_biqueue.hpp:138
~basic_binary_queue()
Definition: mn_biqueue.hpp:95
const_iterator begin() const
Get the begin iterator.
Definition: mn_biqueue.hpp:116
reference item()
Definition: mn_biqueue.hpp:130
T & reference
Definition: mn_biqueue.hpp:82
Binary queue with overwrite. This queue can only hold one item. If sucessive Enqueue operations are c...
Definition: mn_binaryqueue.hpp:32
virtual int destroy()
Definition: mn_queue.cpp:41
virtual int create()
Definition: mn_queue.cpp:34
#define MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT
Definition: mn_config.hpp:387
#define ERR_QUEUE_OK
Definition: mn_error.hpp:137
void swap(basic_any &x, basic_any &y) noexcept
Definition: mn_any.hpp:272
struct mn::memory::detail::ptr_difference T
Definition: mn_atomic_singleton.hpp:38
basic_binaryqueue binaryqueue_t
Definition: mn_binaryqueue.hpp:53
Definition: mn_allocator_typetraits.hpp:25
long ptrdiff_t
Definition: mn_def.hpp:49
Definition: mn_iterator.hpp:34