1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__PriorityQueueAlgorithm__hxx__
6 #define __fpa__Filters__PriorityQueueAlgorithm__hxx__
8 // -------------------------------------------------------------------------
9 template< class _TDataInterface >
10 fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
11 PriorityQueueAlgorithm( bool double_buffer )
14 m_DoubleBuffer( double_buffer )
18 // -------------------------------------------------------------------------
19 template< class _TDataInterface >
20 fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
21 ~PriorityQueueAlgorithm( )
25 // -------------------------------------------------------------------------
26 template< class _TDataInterface >
27 void fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
30 if( this->m_DoubleBuffer )
31 this->m_CurrQueue = ( this->m_CurrQueue + 1 ) % 2;
33 this->m_CurrQueue = 0;
36 // -------------------------------------------------------------------------
37 template< class _TDataInterface >
38 void fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
41 this->m_Queues[ 0 ].clear( );
42 this->m_Queues[ 1 ].clear( );
43 this->m_CurrQueue = 0;
46 // -------------------------------------------------------------------------
47 template< class _TDataInterface >
48 typename fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
49 TNode fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
53 this->m_Queues[ this->m_CurrQueue ].begin( ),
54 this->m_Queues[ this->m_CurrQueue ].end( ),
57 TNode n = this->m_Queues[ this->m_CurrQueue ].back( );
58 this->m_Queues[ this->m_CurrQueue ].pop_back( );
62 // -------------------------------------------------------------------------
63 template< class _TDataInterface >
64 void fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
65 _QueuePush( const TNode& n )
67 bool push_needed = ( n.Parent == n.Vertex );
68 push_needed |= !( n.Value < this->_GetOutputValue( n.Parent ) );
71 this->m_Queues[ this->m_CurrQueue ].push_back( n );
73 this->m_Queues[ this->m_CurrQueue ].begin( ),
74 this->m_Queues[ this->m_CurrQueue ].end( ),
81 // -------------------------------------------------------------------------
82 template< class _TDataInterface >
83 unsigned long fpa::Filters::PriorityQueueAlgorithm< _TDataInterface >::
86 return( this->m_Queues[ this->m_CurrQueue ].size( ) );
89 #endif // __fpa__Filters__PriorityQueueAlgorithm__hxx__