]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Filters/PriorityQueueAlgorithm.h
...
[FrontAlgorithms.git] / lib / fpa / Filters / PriorityQueueAlgorithm.h
diff --git a/lib/fpa/Filters/PriorityQueueAlgorithm.h b/lib/fpa/Filters/PriorityQueueAlgorithm.h
new file mode 100644 (file)
index 0000000..780e4d2
--- /dev/null
@@ -0,0 +1,71 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __fpa__Filters__PriorityQueueAlgorithm__h__
+#define __fpa__Filters__PriorityQueueAlgorithm__h__
+
+#include <vector>
+#include <fpa/Config.h>
+
+namespace fpa
+{
+  namespace Filters
+  {
+    /**
+     */
+    template< class _TDataInterface >
+    class PriorityQueueAlgorithm
+      : public _TDataInterface
+    {
+    public:
+      typedef _TDataInterface                 Superclass;
+      typedef PriorityQueueAlgorithm                  Self;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
+
+      typedef typename Superclass::TTraits TTraits;
+      fpaTraitsMacro( typename TTraits );
+
+      typedef std::vector< TNode > TQueue;
+      struct TQueueOrder
+      {
+        bool operator()( const TNode& a, const TNode& b ) const
+          {
+            return( b.Value < a.Value );
+          }
+      };
+
+    public:
+      itkTypeMacro( fpa::Filters::PriorityQueueAlgorithm, TDataInterface );
+
+    protected:
+      PriorityQueueAlgorithm( bool double_buffer );
+      virtual ~PriorityQueueAlgorithm( );
+
+      virtual void _QueueSwap( );
+      virtual void _QueueClear( ) override;
+      virtual TNode _QueuePop( ) override;
+      virtual void _QueuePush( const TNode& n ) override;
+      virtual unsigned long _QueueSize( ) const override;
+
+    private:
+      PriorityQueueAlgorithm( const Self& other );
+      Self& operator=( const Self& other );
+
+    protected:
+      TQueue       m_Queues[ 2 ];
+      TQueueOrder  m_QueueOrder;
+      unsigned int m_CurrQueue;
+      bool         m_DoubleBuffer;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#  include <fpa/Filters/PriorityQueueAlgorithm.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+#endif // __fpa__Filters__PriorityQueueAlgorithm__h__
+// eof - $RCSfile$