Skip to content

Commit

Permalink
first round of replacing deprecated typedefs with much nicer using st…
Browse files Browse the repository at this point in the history
…atements
  • Loading branch information
DennisOSRM committed Aug 19, 2014
1 parent 7edf2bb commit 82c2ae5
Show file tree
Hide file tree
Showing 37 changed files with 92 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Algorithms/DouglasPeucker.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DouglasPeucker
private:
std::vector<int> douglas_peucker_thresholds;

typedef std::pair<unsigned, unsigned> GeometryRange;
using GeometryRange = std::pair<unsigned, unsigned>;
// Stack to simulate the recursion
std::stack<GeometryRange> recursion_stack;

Expand Down
2 changes: 1 addition & 1 deletion Algorithms/IteratorBasedCRC32.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IteratorbasedCRC32
unsigned crc = 0;
while (iter != end)
{
typedef typename std::iterator_traits<Iterator>::value_type value_type;
using value_type = typename std::iterator_traits<Iterator>::value_type;
char *data = (char *)(&(*iter));

if (use_hardware_implementation)
Expand Down
12 changes: 6 additions & 6 deletions Algorithms/StronglyConnectedComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ class TarjanSCC
NodeID parent;
};

typedef DynamicGraph<TarjanEdgeData> TarjanDynamicGraph;
typedef TarjanDynamicGraph::InputEdge TarjanEdge;
typedef std::pair<NodeID, NodeID> RestrictionSource;
typedef std::pair<NodeID, bool> RestrictionTarget;
typedef std::vector<RestrictionTarget> EmanatingRestrictionsVector;
typedef std::unordered_map<RestrictionSource, unsigned> RestrictionMap;
using TarjanDynamicGraph = DynamicGraph<TarjanEdgeData>;
using TarjanEdge = TarjanDynamicGraph::InputEdge;
using RestrictionSource = std::pair<NodeID, NodeID>;
using RestrictionTarget = std::pair<NodeID, bool>;
using EmanatingRestrictionsVector = std::vector<RestrictionTarget>;
using RestrictionMap = std::unordered_map<RestrictionSource, unsigned>;

std::vector<NodeInfo> m_coordinate_list;
std::vector<EmanatingRestrictionsVector> m_restriction_bucket_list;
Expand Down
6 changes: 3 additions & 3 deletions Benchmarks/StaticRTreeBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ constexpr int32_t WORLD_MAX_LAT = 90*COORDINATE_PRECISION;
constexpr int32_t WORLD_MIN_LON = -180*COORDINATE_PRECISION;
constexpr int32_t WORLD_MAX_LON = 180*COORDINATE_PRECISION;

typedef EdgeBasedNode RTreeLeaf;
typedef std::shared_ptr<std::vector<FixedPointCoordinate>> FixedPointCoordinateListPtr;
typedef StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, false>::vector, false> BenchStaticRTree;
using RTreeLeaf = EdgeBasedNode;
using FixedPointCoordinateListPtr = std::shared_ptr<std::vector<FixedPointCoordinate>>;
using BenchStaticRTree = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, false>::vector, false>;

FixedPointCoordinateListPtr LoadCoordinates(const boost::filesystem::path& nodes_file)
{
Expand Down
13 changes: 6 additions & 7 deletions Contractor/Contractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ class Contractor
ContractorHeapData(short h, bool t) : hop(h), target(t) {}
};

typedef DynamicGraph<ContractorEdgeData> ContractorGraph;
// typedef BinaryHeap< NodeID, NodeID, int, ContractorHeapData, ArrayStorage<NodeID, NodeID>
// > ContractorHeap;
typedef BinaryHeap<NodeID, NodeID, int, ContractorHeapData, XORFastHashStorage<NodeID, NodeID>>
ContractorHeap;
typedef ContractorGraph::InputEdge ContractorEdge;
using ContractorGraph = DynamicGraph<ContractorEdgeData>;
// using ContractorHeap = BinaryHeap<NodeID, NodeID, int, ContractorHeapData, ArrayStorage<NodeID, NodeID>
// >;
using ContractorHeap = BinaryHeap<NodeID, NodeID, int, ContractorHeapData, XORFastHashStorage<NodeID, NodeID>>;
using ContractorEdge = ContractorGraph::InputEdge;

struct ContractorThreadData
{
Expand Down Expand Up @@ -151,7 +150,7 @@ class Contractor
}

int number_of_nodes;
typedef tbb::enumerable_thread_specific<std::shared_ptr<ContractorThreadData>> EnumerableThreadData;
using EnumerableThreadData = tbb::enumerable_thread_specific<std::shared_ptr<ContractorThreadData>>;
EnumerableThreadData data;
};

Expand Down
2 changes: 1 addition & 1 deletion Contractor/EdgeBasedGraphFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class EdgeBasedGraphFactory
} speed_profile;

private:
typedef NodeBasedDynamicGraph::EdgeData EdgeData;
using EdgeData = NodeBasedDynamicGraph::EdgeData;

unsigned m_number_of_edge_based_nodes;

Expand Down
2 changes: 1 addition & 1 deletion Contractor/GeometryCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class GeometryCompressor
{
public:
typedef std::pair<NodeID, EdgeWeight> CompressedNode;
using CompressedNode = std::pair<NodeID, EdgeWeight>;

GeometryCompressor();
void CompressEdge(const EdgeID surviving_edge_id,
Expand Down
6 changes: 3 additions & 3 deletions Contractor/Prepare.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
class Prepare
{
public:
typedef QueryEdge::EdgeData EdgeData;
typedef DynamicGraph<EdgeData>::InputEdge InputEdge;
typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
using EdgeData = QueryEdge::EdgeData;
using InputEdge = DynamicGraph<EdgeData>::InputEdge;
using StaticEdge = StaticGraph<EdgeData>::InputEdge;

explicit Prepare();
Prepare(const Prepare &) = delete;
Expand Down
4 changes: 2 additions & 2 deletions DataStructures/BinaryHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class BinaryHeap
void operator=(const BinaryHeap &right);

public:
typedef Weight WeightType;
typedef Data DataType;
using WeightType = Weight;
using DataType = Data;

explicit BinaryHeap(size_t maxID) : node_index(maxID) { Clear(); }

Expand Down
6 changes: 3 additions & 3 deletions DataStructures/DeallocatingVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ class DeallocatingVector
std::vector<ElementT *> bucket_list;

public:
typedef DeallocatingVectorIterator<ElementT, ELEMENTS_PER_BLOCK> iterator;
typedef DeallocatingVectorIterator<ElementT, ELEMENTS_PER_BLOCK> const_iterator;
using iterator = DeallocatingVectorIterator<ElementT, ELEMENTS_PER_BLOCK>;
using const_iterator = DeallocatingVectorIterator<ElementT, ELEMENTS_PER_BLOCK>;

// this forward-only iterator deallocates all buckets that have been visited
typedef DeallocatingVectorRemoveIterator<ElementT, ELEMENTS_PER_BLOCK> deallocation_iterator;
using deallocation_iterator = DeallocatingVectorRemoveIterator<ElementT, ELEMENTS_PER_BLOCK>;

DeallocatingVector() : current_size(0) { bucket_list.emplace_back(new ElementT[ELEMENTS_PER_BLOCK]); }

Expand Down
8 changes: 4 additions & 4 deletions DataStructures/DynamicGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
template <typename EdgeDataT> class DynamicGraph
{
public:
typedef EdgeDataT EdgeData;
typedef unsigned NodeIterator;
typedef unsigned EdgeIterator;
typedef osrm::range<EdgeIterator> EdgeRange;
using EdgeData = EdgeDataT;
using NodeIterator = unsigned;
using EdgeIterator = unsigned;
using EdgeRange = osrm::range<EdgeIterator>;

class InputEdge
{
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/HashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ template <typename Key, typename Value>
class HashTable
{
private:
typedef std::pair<Key, Value> KeyValPair;
using KeyValPair = std::pair<Key, Value>;
std::vector<KeyValPair> table;

public:
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/ImportEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ struct EdgeBasedEdge
bool backward : 1;
};

typedef NodeBasedEdge ImportEdge;
using ImportEdge = NodeBasedEdge;

#endif /* IMPORT_EDGE_H */
4 changes: 2 additions & 2 deletions DataStructures/JSONContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ struct Null
{
};

typedef mapbox::util::variant<String,
using Value = mapbox::util::variant<String,
Number,
mapbox::util::recursive_wrapper<Object>,
mapbox::util::recursive_wrapper<Array>,
True,
False,
Null > Value;
Null>;

struct Object
{
Expand Down
4 changes: 2 additions & 2 deletions DataStructures/NodeBasedGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ struct SimpleEdgeData
EdgeWeight capacity;
};

typedef DynamicGraph<NodeBasedEdgeData> NodeBasedDynamicGraph;
typedef DynamicGraph<SimpleEdgeData> SimpleNodeBasedDynamicGraph;
using NodeBasedDynamicGraph = DynamicGraph<NodeBasedEdgeData>;
using SimpleNodeBasedDynamicGraph = DynamicGraph<SimpleEdgeData>;

// Factory method to create NodeBasedDynamicGraph from ImportEdges
inline std::shared_ptr<NodeBasedDynamicGraph>
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/PhantomNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct PhantomNode
}
};

typedef std::vector<std::vector<PhantomNode>> PhantomNodeArray;
using PhantomNodeArray = std::vector<std::vector<PhantomNode>>;

struct PhantomNodeLists
{
Expand Down
4 changes: 2 additions & 2 deletions DataStructures/QueryNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

struct NodeInfo
{
typedef NodeID key_type; // type of NodeID
typedef int value_type; // type of lat,lons
using key_type = NodeID; // type of NodeID
using value_type = int; // type of lat,lons

explicit NodeInfo(int lat, int lon, NodeID node_id) : lat(lat), lon(lon), node_id(node_id) {}
NodeInfo()
Expand Down
8 changes: 4 additions & 4 deletions DataStructures/RangeTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class RangeTable
{
public:

typedef std::array<unsigned char, BLOCK_SIZE> BlockT;
typedef typename ShM<BlockT, USE_SHARED_MEMORY>::vector BlockContainerT;
typedef typename ShM<unsigned, USE_SHARED_MEMORY>::vector OffsetContainerT;
typedef osrm::range<unsigned> RangeT;
using BlockT = std::array<unsigned char, BLOCK_SIZE>;
using BlockContainerT = typename ShM<BlockT, USE_SHARED_MEMORY>::vector;
using OffsetContainerT = typename ShM<unsigned, USE_SHARED_MEMORY>::vector;
using RangeT = osrm::range<unsigned>;

friend std::ostream& operator<< <>(std::ostream &out, const RangeTable &table);
friend std::istream& operator>> <>(std::istream &in, RangeTable &table);
Expand Down
4 changes: 2 additions & 2 deletions DataStructures/Restriction.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct InputRestrictionContainer

struct CmpRestrictionContainerByFrom
{
typedef InputRestrictionContainer value_type;
using value_type = InputRestrictionContainer;
inline bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b)
const
{
Expand All @@ -113,7 +113,7 @@ struct CmpRestrictionContainerByFrom

struct CmpRestrictionContainerByTo
{
typedef InputRestrictionContainer value_type;
using value_type = InputRestrictionContainer;
inline bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b)
const
{
Expand Down
8 changes: 4 additions & 4 deletions DataStructures/RestrictionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __RESTRICTION_MAP_H__
#define __RESTRICTION_MAP_H__
#ifndef RESTRICTION_MAP_H__
#define RESTRICTION_MAP_H__

#include <memory>

Expand Down Expand Up @@ -110,8 +110,8 @@ class RestrictionMap

private:
bool IsSourceNode(const NodeID node) const;
typedef std::vector<RestrictionTarget> EmanatingRestrictionsVector;
typedef NodeBasedDynamicGraph::EdgeData EdgeData;
using EmanatingRestrictionsVector = std::vector<RestrictionTarget>;
using EdgeData = NodeBasedDynamicGraph::EdgeData;

std::size_t m_count;
std::shared_ptr<NodeBasedDynamicGraph> m_graph;
Expand Down
4 changes: 2 additions & 2 deletions DataStructures/SearchEngineData.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct HeapData

struct SearchEngineData
{
typedef BinaryHeap<NodeID, NodeID, int, HeapData, UnorderedMapStorage<NodeID, int>> QueryHeap;
typedef boost::thread_specific_ptr<QueryHeap> SearchEngineHeapPtr;
using QueryHeap = BinaryHeap<NodeID, NodeID, int, HeapData, UnorderedMapStorage<NodeID, int>>;
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;

static SearchEngineHeapPtr forwardHeap;
static SearchEngineHeapPtr backwardHeap;
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/SharedMemoryFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,6 @@ template <class LockFileT = OSRMLockFile> class SharedMemoryFactory_tmpl
SharedMemoryFactory_tmpl(const SharedMemoryFactory_tmpl &) = delete;
};

typedef SharedMemoryFactory_tmpl<> SharedMemoryFactory;
using SharedMemoryFactory = SharedMemoryFactory_tmpl<>;

#endif /* SHARED_MEMORY_POINTER_FACTORY_H */
4 changes: 2 additions & 2 deletions DataStructures/SharedMemoryVectorWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ template <> class SharedMemoryWrapper<bool>

template <typename DataT, bool UseSharedMemory> struct ShM
{
typedef typename std::conditional<UseSharedMemory,
using vector = typename std::conditional<UseSharedMemory,
SharedMemoryWrapper<DataT>,
std::vector<DataT>>::type vector;
std::vector<DataT>>::type;
};

#endif // SHARED_MEMORY_VECTOR_WRAPPER_H
8 changes: 4 additions & 4 deletions DataStructures/StaticGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
{
public:
typedef NodeID NodeIterator;
typedef NodeID EdgeIterator;
typedef EdgeDataT EdgeData;
typedef osrm::range<EdgeIterator> EdgeRange;
using NodeIterator = NodeID;
using EdgeIterator = NodeID;
using EdgeData = EdgeDataT;
using EdgeRange = osrm::range<EdgeIterator>;

class InputEdge
{
Expand Down
2 changes: 1 addition & 1 deletion DataStructures/StaticKDTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class StaticKDTree
}

private:
typedef unsigned Iterator;
using Iterator = unsigned;
struct Tree
{
Iterator left;
Expand Down
4 changes: 2 additions & 2 deletions DataStructures/StaticRTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class StaticRTree
}
};

typedef RectangleInt2D RectangleT;
using RectangleT = RectangleInt2D;

struct TreeNode
{
Expand Down Expand Up @@ -307,7 +307,7 @@ class StaticRTree
}
};

typedef mapbox::util::variant<TreeNode, EdgeDataT> IncrementalQueryNodeType;
using IncrementalQueryNodeType = mapbox::util::variant<TreeNode, EdgeDataT>;
struct IncrementalQueryCandidate
{
explicit IncrementalQueryCandidate(const float dist, const IncrementalQueryNodeType &node)
Expand Down
12 changes: 6 additions & 6 deletions Extractor/ExtractionContainers.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class ExtractionContainers
const static unsigned stxxl_memory = ((sizeof(std::size_t) == 4) ? INT_MAX : UINT_MAX);
#endif
public:
typedef stxxl::vector<NodeID> STXXLNodeIDVector;
typedef stxxl::vector<ExternalMemoryNode> STXXLNodeVector;
typedef stxxl::vector<InternalExtractorEdge> STXXLEdgeVector;
typedef stxxl::vector<std::string> STXXLStringVector;
typedef stxxl::vector<InputRestrictionContainer> STXXLRestrictionsVector;
typedef stxxl::vector<WayIDStartAndEndEdge> STXXLWayIDStartEndVector;
using STXXLNodeIDVector = stxxl::vector<NodeID>;
using STXXLNodeVector = stxxl::vector<ExternalMemoryNode>;
using STXXLEdgeVector = stxxl::vector<InternalExtractorEdge>;
using STXXLStringVector = stxxl::vector<std::string>;
using STXXLRestrictionsVector = stxxl::vector<InputRestrictionContainer>;
using STXXLWayIDStartEndVector = stxxl::vector<WayIDStartAndEndEdge>;

STXXLNodeIDVector used_node_id_list;
STXXLNodeVector all_nodes_list;
Expand Down
6 changes: 3 additions & 3 deletions Extractor/ExtractorStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct WayIDStartAndEndEdge

struct CmpWayByID
{
typedef WayIDStartAndEndEdge value_type;
using value_type = WayIDStartAndEndEdge;
bool operator()(const WayIDStartAndEndEdge &a, const WayIDStartAndEndEdge &b) const
{
return a.wayID < b.wayID;
Expand All @@ -94,15 +94,15 @@ struct CmpWayByID

struct Cmp
{
typedef NodeID value_type;
using value_type = NodeID;
bool operator()(const NodeID left, const NodeID right) const { return left < right; }
value_type max_value() { return 0xffffffff; }
value_type min_value() { return 0x0; }
};

struct CmpNodeByID
{
typedef ExternalMemoryNode value_type;
using value_type = ExternalMemoryNode;
bool operator()(const ExternalMemoryNode &left, const ExternalMemoryNode &right) const
{
return left.node_id < right.node_id;
Expand Down
Loading

0 comments on commit 82c2ae5

Please sign in to comment.