Skip to content

Commit

Permalink
Merge branch 'develop' into feature/miguel_develop_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicDirkx committed Sep 11, 2023
2 parents 2cc483f + e4b2133 commit 966974c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.12.1.dev23
current_version = 2.12.1.dev24
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
Expand Down
20 changes: 20 additions & 0 deletions include/tudat/basics/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef TUDAT_UTILITIES_H
#define TUDAT_UTILITIES_H

#include <unordered_map>
#include <map>
#include <vector>
#include <iostream>
Expand Down Expand Up @@ -92,6 +93,25 @@ std::vector< VectorArgument > createVectorFromMapValues( const std::map< KeyType
return outputVector;
}

template< typename VectorArgument, typename KeyType >
std::vector< KeyType > createVectorFromUnorderedMapKeys( const std::unordered_map< KeyType, VectorArgument >& inputMap )
{
// Create and size return vector.
std::vector< KeyType > outputVector;
outputVector.resize( inputMap.size( ) );

// Iterate over all map entries and create vector
int currentIndex = 0;
for( typename std::unordered_map< KeyType, VectorArgument >::const_iterator mapIterator = inputMap.begin( );
mapIterator != inputMap.end( ); mapIterator++, currentIndex++ )
{
outputVector[ currentIndex ] = mapIterator->first;
}

return outputVector;
}


//! Function to create a vector from the keys of a map
/*!
* Function to create a vector from the keys of a map. The output vector is in the order of the map entries, i.e. as provided by a forward iterator.
Expand Down
10 changes: 10 additions & 0 deletions include/tudat/simulation/environment_setup/body.h
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,16 @@ class SystemOfBodies
return bodyMap_.count( bodyName );
}

bool doesBodyExist( const std::string& bodyName ) const
{
return ( this->count( bodyName ) != 0 );
}

std::vector< std::string > getListOfBodies( ) const
{
return utilities::createVectorFromUnorderedMapKeys( bodyMap_ );
}

int getNumberOfBodies( ) const
{
return bodyMap_.size( );
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.12.1.dev23
2.12.1.dev24

0 comments on commit 966974c

Please sign in to comment.