Skip to content

Commit

Permalink
Switch to unordered_map. [closes #16]
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Oct 9, 2019
1 parent ae10136 commit 9127f1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/AABB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ namespace aabb
insertLeaf(node);

// Add the new particle to the map.
particleMap.insert(std::map<unsigned int, unsigned int>::value_type(particle, node));
particleMap.insert(std::unordered_map<unsigned int, unsigned int>::value_type(particle, node));

// Store the particle index.
nodes[node].particle = particle;
Expand Down Expand Up @@ -435,7 +435,7 @@ namespace aabb
insertLeaf(node);

// Add the new particle to the map.
particleMap.insert(std::map<unsigned int, unsigned int>::value_type(particle, node));
particleMap.insert(std::unordered_map<unsigned int, unsigned int>::value_type(particle, node));

// Store the particle index.
nodes[node].particle = particle;
Expand All @@ -449,7 +449,7 @@ namespace aabb
void Tree::removeParticle(unsigned int particle)
{
// Map iterator.
std::map<unsigned int, unsigned int>::iterator it;
std::unordered_map<unsigned int, unsigned int>::iterator it;

// Find the particle.
it = particleMap.find(particle);
Expand All @@ -476,7 +476,7 @@ namespace aabb
void Tree::removeAll()
{
// Iterator pointing to the start of the particle map.
std::map<unsigned int, unsigned int>::iterator it = particleMap.begin();
std::unordered_map<unsigned int, unsigned int>::iterator it = particleMap.begin();

// Iterate over the map.
while (it != particleMap.end())
Expand Down Expand Up @@ -531,7 +531,7 @@ namespace aabb
}

// Map iterator.
std::map<unsigned int, unsigned int>::iterator it;
std::unordered_map<unsigned int, unsigned int>::iterator it;

// Find the particle.
it = particleMap.find(particle);
Expand Down
4 changes: 2 additions & 2 deletions src/AABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <cstdlib>
#include <iostream>
#include <limits>
#include <map>
#include <stdexcept>
#include <unordered_map>
#include <vector>

/// Null node flag.
Expand Down Expand Up @@ -416,7 +416,7 @@ namespace aabb
std::vector<double> posMinImage;

/// A map between particle and node indices.
std::map<unsigned int, unsigned int> particleMap;
std::unordered_map<unsigned int, unsigned int> particleMap;

/// Does touching count as overlapping in tree queries?
bool touchIsOverlap;
Expand Down

0 comments on commit 9127f1b

Please sign in to comment.