Queue::const_iterator Queue::end() const
{ return _pimpl->elements + _pimpl->count;}
- void Queue::push( value_type val_r )
- { ::queue_push( _pimpl, val_r ); }
-
- Queue::value_type Queue::pop()
- { return ::queue_pop( _pimpl ); }
+ Queue::const_iterator Queue::find( value_type val_r ) const
+ {
+ for_( it, begin(), end() )
+ if ( *it != val_r )
+ return it;
+ return end();
+ }
Queue::value_type Queue::first() const
{
return *_pimpl->elements;
}
+ Queue::value_type Queue::last() const
+ {
+ if ( empty() )
+ return 0;
+ return _pimpl->elements[_pimpl->count-1];
+ }
+
void Queue::clear()
{ ::queue_empty( *this ); }
+ void Queue::remove( value_type val_r )
+ {
+ const_iterator it( find( val_r ) );
+ if ( it != end() )
+ {
+ ::queue_delete( _pimpl, it - begin() );
+ }
+ }
+
+ void Queue::push( value_type val_r )
+ { ::queue_push( _pimpl, val_r ); }
+
+ Queue::value_type Queue::pop()
+ { return ::queue_pop( _pimpl ); }
+
+ void Queue::push_front( value_type val_r )
+ { ::queue_unshift( _pimpl, val_r ); }
+
+ Queue::value_type Queue::pop_front()
+ { return ::queue_shift( _pimpl ); }
+
std::ostream & operator<<( std::ostream & str, const Queue & obj )
{ return dumpRangeLine( str << "Queue ", obj.begin(), obj.end() ); }
const_iterator begin() const;
const_iterator end() const;
+ /** Return iterator to the 1st occurance of \a val_r or \ref end. */
+ const_iterator find( value_type val_r ) const;
+
+ /** Return whether the Queue contais at lest one element with value \a val_r. */
+ bool contains( value_type val_r ) const
+ { return( find( val_r ) != end() ); }
+
+ /** Return the 1st Id in the queue or \c 0 if empty. */
+ value_type first() const;
+
+ /** Return the last Id in the queue or \c 0 if empty. */
+ value_type last() const;
+
/** Clear the queue. */
void clear();
+ /** Remove all occurances of \a val_r from the queue. */
+ void remove( value_type val_r );
+
/** Push a value to the end off the Queue. */
void push( value_type val_r );
+ /** \overload */
+ void push_back( value_type val_r )
+ { push( val_r ); }
- /** Return the 1st Id in the queue or \c 0 if empty. */
+ /** Pop and return the last Id from the queue or \c 0 if empty. */
value_type pop();
+ /** \overload */
+ value_type pop_back()
+ { return pop(); }
- /** Remove and return the 1st Id from the queue or \c 0 if empty. */
- value_type first() const;
+ /** Push a value to the beginning off the Queue. */
+ void push_front( value_type val_r );
- public:
+ /** Pop and return the 1st Id from the queue or \c 0 if empty. */
+ value_type pop_front();
+
+ public:
/** Backdoor */
operator struct ::_Queue *()
{ return _pimpl; }