Geant4  10.00.p01
G4KDMap.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 #ifndef G4ITMAPROOM_HH
27 #define G4ITMAPROOM_HH
28 
29 #include <map>
30 //#include <unordered_map>
31 #include <vector>
32 #include <deque>
33 #include <cmath>
34 #include <iostream>
35 
36 #include "G4KDNode.hh"
37 
39 {
40 public :
41  __1DSortOut(int dimension);
42  int GetDimension();
43  G4KDNode *GetMidle(int& G4KDNode_deque);
44 
45  //std::_Deque_iterator<G4KDNode*,G4KDNode*&,G4KDNode**> Insert(G4KDNode*);
46 
47  std::deque<G4KDNode*>::iterator Insert(G4KDNode*);
49  void Sort();
50  //void Erase(std::_Deque_iterator<G4KDNode*,G4KDNode*&,G4KDNode**>&);
51  void Erase(std::deque<G4KDNode*>::iterator &);
52 
53 protected :
54  struct sortOutNDim
55  {
56  sortOutNDim( int dimension)
57  {
58  fDimension = dimension;
59  }
60 
61  bool operator() (G4KDNode* const& lhs, G4KDNode* const& rhs) //const
62  {
63  return lhs->GetPosition()[fDimension] < rhs->GetPosition()[fDimension];
64  }
65 
67  };
68 
69  std::deque<G4KDNode*> fContainer;
71 };
72 
73 class G4KDMap
74 {
75 public:
76  G4KDMap(int dimensions) : fSortOut(dimensions)
77  {
78  fIsSorted = false;
79  for(int i = 0 ; i < dimensions ; i++)
80  {
81  fSortOut[i] = new __1DSortOut(i);
82  }
83  }
84 
85  void Insert(G4KDNode* pos);
86  void Sort();
87 
88  G4KDNode* PopOutMiddle(int dimension);
90  {
91  return fSortOut.size();
92  }
93 
94  size_t GetSize()
95  {
96  return fMap.size();
97  }
98 
99 private:
100  bool fIsSorted;
101  std::vector<__1DSortOut*> fSortOut;
102  // std::map<G4KDNode*, std::vector<std::_Deque_iterator<G4KDNode*,G4KDNode*&,G4KDNode**> > > fMap;
103 
104  std::map<G4KDNode*, std::vector<std::deque<G4KDNode*>::iterator > > fMap;
105 };
106 
107 
108 #endif // G4ITMAPROOM_HH
int GetDimension()
Definition: G4KDMap.hh:89
G4KDNode * PopOutMiddle(int dimension)
Definition: G4KDMap.cc:92
G4KDNode * GetMidle(int &G4KDNode_deque)
Definition: G4KDMap.cc:42
size_t GetSize()
Definition: G4KDMap.hh:94
void Sort()
Definition: G4KDMap.cc:112
G4KDNode * PopOutMiddle()
Definition: G4KDMap.cc:54
std::deque< G4KDNode * > fContainer
Definition: G4KDMap.hh:69
__1DSortOut(int dimension)
Definition: G4KDMap.cc:34
void Erase(std::deque< G4KDNode * >::iterator &)
Definition: G4KDMap.cc:68
G4KDNode stores one entity in G4KDTree This class is for internal use only.
Definition: G4KDNode.hh:50
G4KDMap(int dimensions)
Definition: G4KDMap.hh:76
std::map< G4KDNode *, std::vector< std::deque< G4KDNode * >::iterator > > fMap
Definition: G4KDMap.hh:104
sortOutNDim fSortOutNDim
Definition: G4KDMap.hh:70
std::vector< __1DSortOut * > fSortOut
Definition: G4KDMap.hh:101
const double * GetPosition()
Definition: G4KDNode.hh:127
sortOutNDim(int dimension)
Definition: G4KDMap.hh:56
int GetDimension()
Definition: G4KDMap.cc:37
std::deque< G4KDNode * >::iterator Insert(G4KDNode *)
Definition: G4KDMap.cc:49
void Sort()
Definition: G4KDMap.cc:63
bool operator()(G4KDNode *const &lhs, G4KDNode *const &rhs)
Definition: G4KDMap.hh:61
bool fIsSorted
Definition: G4KDMap.hh:100
static const G4double pos
void Insert(G4KDNode *pos)
Definition: G4KDMap.cc:73