Ref'ed and consted parameters. Gives some extra performance when
creating grid.
This commit is contained in:
parent
811d77eccb
commit
086e10671f
@ -49,7 +49,7 @@ class DynamicGraph {
|
|||||||
m_nodes.reserve( m_numNodes );
|
m_nodes.reserve( m_numNodes );
|
||||||
m_nodes.resize( m_numNodes );
|
m_nodes.resize( m_numNodes );
|
||||||
|
|
||||||
m_edges.reserve( m_numNodes * 1.2 );
|
m_edges.reserve( m_numNodes * 1.1 );
|
||||||
m_edges.resize( m_numNodes );
|
m_edges.resize( m_numNodes );
|
||||||
}
|
}
|
||||||
DynamicGraph( int nodes, const std::vector< InputEdge > &graph )
|
DynamicGraph( int nodes, const std::vector< InputEdge > &graph )
|
||||||
@ -69,7 +69,7 @@ class DynamicGraph {
|
|||||||
m_nodes[node].edges = edge - lastEdge;
|
m_nodes[node].edges = edge - lastEdge;
|
||||||
position += m_nodes[node].edges;
|
position += m_nodes[node].edges;
|
||||||
}
|
}
|
||||||
m_edges.reserve( position * 1.2 );
|
m_edges.reserve( position * 1.1 );
|
||||||
m_edges.resize( position );
|
m_edges.resize( position );
|
||||||
edge = 0;
|
edge = 0;
|
||||||
for ( NodeIterator node = 0; node < m_numNodes; ++node ) {
|
for ( NodeIterator node = 0; node < m_numNodes; ++node ) {
|
||||||
|
@ -100,6 +100,7 @@ public:
|
|||||||
|
|
||||||
template<typename EdgeT>
|
template<typename EdgeT>
|
||||||
void ConstructGrid(std::vector<EdgeT> & edgeList, char * ramIndexOut, char * fileIndexOut) {
|
void ConstructGrid(std::vector<EdgeT> & edgeList, char * ramIndexOut, char * fileIndexOut) {
|
||||||
|
//TODO: Implement this using STXXL-Streams
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
Percent p(edgeList.size());
|
Percent p(edgeList.size());
|
||||||
BOOST_FOREACH(EdgeT & edge, edgeList) {
|
BOOST_FOREACH(EdgeT & edge, edgeList) {
|
||||||
@ -298,7 +299,7 @@ private:
|
|||||||
return (std::fabs(d1 - d2) < 0.0001);
|
return (std::fabs(d1 - d2) < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned FillCell(std::vector<GridEntry>& entriesWithSameRAMIndex, unsigned long fileOffset ) {
|
unsigned FillCell(std::vector<GridEntry>& entriesWithSameRAMIndex, const unsigned long fileOffset ) {
|
||||||
vector<char> tmpBuffer(32*32*4096,0);
|
vector<char> tmpBuffer(32*32*4096,0);
|
||||||
unsigned long indexIntoTmpBuffer = 0;
|
unsigned long indexIntoTmpBuffer = 0;
|
||||||
unsigned numberOfWrittenBytes = 0;
|
unsigned numberOfWrittenBytes = 0;
|
||||||
@ -373,7 +374,7 @@ private:
|
|||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(GridEntry entry, vectorWithSameFileIndex) {
|
BOOST_FOREACH(const GridEntry & entry, vectorWithSameFileIndex) {
|
||||||
char * data = (char *)&(entry.edge);
|
char * data = (char *)&(entry.edge);
|
||||||
for(unsigned i = 0; i < sizeof(_GridEdge); ++i) {
|
for(unsigned i = 0; i < sizeof(_GridEdge); ++i) {
|
||||||
tmpBuffer[index+counter] = data[i];
|
tmpBuffer[index+counter] = data[i];
|
||||||
@ -419,7 +420,7 @@ private:
|
|||||||
localStream->read((char *)&result[currentSizeOfResult], lengthOfBucket*sizeof(_GridEdge));
|
localStream->read((char *)&result[currentSizeOfResult], lengthOfBucket*sizeof(_GridEdge));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddEdge(_GridEdge edge) {
|
void AddEdge(const _GridEdge & edge) {
|
||||||
#ifndef ROUTED
|
#ifndef ROUTED
|
||||||
std::vector<BresenhamPixel> indexList;
|
std::vector<BresenhamPixel> indexList;
|
||||||
GetListOfIndexesForEdgeAndGridSize(edge.startCoord, edge.targetCoord, indexList);
|
GetListOfIndexesForEdgeAndGridSize(edge.startCoord, edge.targetCoord, indexList);
|
||||||
@ -468,7 +469,7 @@ private:
|
|||||||
return (p-x)*(p-x) + (q-y)*(q-y);
|
return (p-x)*(p-x) + (q-y)*(q-y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetListOfIndexesForEdgeAndGridSize(_Coordinate& start, _Coordinate& target, std::vector<BresenhamPixel> &indexList) {
|
void GetListOfIndexesForEdgeAndGridSize(const _Coordinate& start, const _Coordinate& target, std::vector<BresenhamPixel> &indexList) {
|
||||||
double lat1 = start.lat/100000.;
|
double lat1 = start.lat/100000.;
|
||||||
double lon1 = start.lon/100000.;
|
double lon1 = start.lon/100000.;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user