VMTK
vtkvmtkMinHeap.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkMinHeap.h,v $
5 Language: C++
6 
7  Copyright (c) Luca Antiga, David Steinman. All rights reserved.
8  See LICENSE file for details.
9 
10  Portions of this code are covered under the VTK copyright.
11  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
12  for details.
13 
14  This software is distributed WITHOUT ANY WARRANTY; without even
15  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  PURPOSE. See the above copyright notices for more information.
17 
18 =========================================================================*/
36 #ifndef __vtkvmtkMinHeap_h
37 #define __vtkvmtkMinHeap_h
38 
39 #include "vtkObject.h"
40 #include "vtkDoubleArray.h"
41 //#include "vtkvmtkComputationalGeometryWin32Header.h"
42 #include "vtkvmtkWin32Header.h"
43 
44 class VTK_VMTK_COMPUTATIONAL_GEOMETRY_EXPORT vtkvmtkMinHeap : public vtkObject
45 {
46  public:
47  vtkTypeMacro(vtkvmtkMinHeap,vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
49 
50  static vtkvmtkMinHeap *New();
51 
55  void Initialize();
56 
58 
59  vtkSetObjectMacro(MinHeapScalars,vtkDoubleArray);
60  vtkGetObjectMacro(MinHeapScalars,vtkDoubleArray);
62 
64  int GetSize();
65 
67  void InsertNextId(vtkIdType id);
68 
71  void UpdateId(vtkIdType id);
72 
74  vtkIdType GetMin();
75 
78  vtkIdType RemoveMin();
79 
80  protected:
82  ~vtkvmtkMinHeap();
83 
84  void Swap(vtkIdType loc0, vtkIdType loc1);
85  int IsLeaf(vtkIdType loc);
86  vtkIdType GetLeftChild(vtkIdType loc);
87  vtkIdType GetRightChild(vtkIdType loc);
88  vtkIdType GetParent(vtkIdType loc);
89  void SiftUp(vtkIdType loc);
90  void SiftDown(vtkIdType loc);
91  vtkIdType RemoveAt(vtkIdType loc);
92 
93  vtkIdList* Heap;
94  vtkIdList* BackPointers;
95 
96  vtkDoubleArray* MinHeapScalars;
97 
98  private:
99  vtkvmtkMinHeap(const vtkvmtkMinHeap&); // Not implemented.
100  void operator=(const vtkvmtkMinHeap&); // Not implemented.
101 };
102 
103 #endif
vtkIdList * BackPointers
vtkDoubleArray * MinHeapScalars
vtkIdList * Heap
Implementation of the min heap data structure.