Commit 429bacc8489f7a24efb4635afe2da645c801e4a5
1 parent
4ce00e42
Replace pop() method by remove() method.
The container class method name pop() was changed to remove() to be complatible with the Python syntax for lists.
Showing
14 changed files
with
34 additions
and
50 deletions
include/GContainer.hpp
| ... | ... | @@ -37,16 +37,15 @@ |
| 37 | 37 | * @brief Interface class for container classes |
| 38 | 38 | * |
| 39 | 39 | * This class defines the interface for container classes. The usage of the |
| 40 | - * interface class imposes on all container classes to implement the following | |
| 41 | - * methods: | |
| 40 | + * interface class imposes on all container classes are coherent interface. | |
| 41 | + * The following methods are mandatory: | |
| 42 | 42 | * |
| 43 | 43 | * clear - Clear container (inherited from GBase) |
| 44 | 44 | * clone - Clones container (inherited from GBase) |
| 45 | 45 | * print - Print container content (inherited from GBase) |
| 46 | - * | |
| 47 | 46 | * size - Returns number of objects is container |
| 48 | - * isempty - Signals if container is empty | |
| 49 | - * pop - Removes an object from the container | |
| 47 | + * isempty - Checks if container is empty | |
| 48 | + * remove - Removes an object from the container | |
| 50 | 49 | * reserve - Reserves space in the container |
| 51 | 50 | ***************************************************************************/ |
| 52 | 51 | class GContainer : public GBase { |
| ... | ... | @@ -71,14 +70,14 @@ public: |
| 71 | 70 | /// |
| 72 | 71 | /// @param[in] index Index. |
| 73 | 72 | /// |
| 74 | - /// Removes the object with the specified index from the container. | |
| 75 | - virtual void pop(const int& index) = 0; | |
| 73 | + /// Removes the object with the specified @p index from the container. | |
| 74 | + virtual void remove(const int& index) = 0; | |
| 76 | 75 | |
| 77 | 76 | /// @brief Reserves space in the container |
| 78 | 77 | /// |
| 79 | 78 | /// @param[in] num Number of objects. |
| 80 | 79 | /// |
| 81 | - /// Reserves space for num objects in the container. | |
| 80 | + /// Reserves space for @p num objects in the container. | |
| 82 | 81 | virtual void reserve(const int& num) = 0; |
| 83 | 82 | }; |
| 84 | 83 | ... | ... |
include/GEbounds.hpp
| ... | ... | @@ -71,7 +71,7 @@ public: |
| 71 | 71 | void insert(const GEnergy& emin, const GEnergy& emax); |
| 72 | 72 | void merge(void); |
| 73 | 73 | void merge(const GEnergy& emin, const GEnergy& emax); |
| 74 | - void pop(const int& index); | |
| 74 | + void remove(const int& index); | |
| 75 | 75 | void reserve(const int& num); |
| 76 | 76 | void extend(const GEbounds& ebds); |
| 77 | 77 | void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); | ... | ... |
include/GGti.hpp
| ... | ... | @@ -72,7 +72,7 @@ public: |
| 72 | 72 | void merge(void); |
| 73 | 73 | void merge(const GTime& tstart, const GTime& tstop); |
| 74 | 74 | void reduce(const GTime& tstart, const GTime& tstop); |
| 75 | - void pop(const int& index); | |
| 75 | + void remove(const int& index); | |
| 76 | 76 | void reserve(const int& num); |
| 77 | 77 | void extend(const GGti& gti); |
| 78 | 78 | void load(const std::string& filename, | ... | ... |
include/GModels.hpp
| ... | ... | @@ -85,8 +85,8 @@ public: |
| 85 | 85 | void append(const GModel& model); |
| 86 | 86 | void insert(const int& index, const GModel& model); |
| 87 | 87 | void insert(const std::string& name, const GModel& model); |
| 88 | - void pop(const int& index); | |
| 89 | - void pop(const std::string& name); | |
| 88 | + void remove(const int& index); | |
| 89 | + void remove(const std::string& name); | |
| 90 | 90 | void reserve(const int& num) { return m_models.reserve(num); } |
| 91 | 91 | void extend(const GModels& models); |
| 92 | 92 | void set(const int& index, const GModel& model); | ... | ... |
include/GOptimizerPars.hpp
| ... | ... | @@ -70,7 +70,7 @@ public: |
| 70 | 70 | virtual GOptimizerPars* clone(void) const = 0; |
| 71 | 71 | virtual int size(void) const = 0; |
| 72 | 72 | virtual bool isempty(void) const = 0; |
| 73 | - virtual void pop(const int& index) = 0; | |
| 73 | + virtual void remove(const int& index) = 0; | |
| 74 | 74 | virtual void reserve(const int& num) = 0; |
| 75 | 75 | virtual std::string print(void) const = 0; |
| 76 | 76 | ... | ... |
pyext/GContainer.i
| ... | ... | @@ -26,7 +26,6 @@ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "GContainer.hpp" |
| 29 | -#include "GTools.hpp" | |
| 30 | 29 | %} |
| 31 | 30 | |
| 32 | 31 | |
| ... | ... | @@ -34,28 +33,15 @@ |
| 34 | 33 | * @class GContainer |
| 35 | 34 | * |
| 36 | 35 | * @brief Interface class for container classes |
| 37 | - * | |
| 38 | - * This class defines the interface for container classes. The usage of the | |
| 39 | - * interface class imposes on all container classes to implement the following | |
| 40 | - * methods: | |
| 41 | - * | |
| 42 | - * clear - Clear container (inherited from GBase) | |
| 43 | - * clone - Clones container (inherited from GBase) | |
| 44 | - * print - Print container content (inherited from GBase) | |
| 45 | - * | |
| 46 | - * size - Returns number of objects is container | |
| 47 | - * isempty - Signals if container is empty | |
| 48 | - * pop - Removes an object from the container | |
| 49 | - * reserve - Reserves space in the container | |
| 50 | 36 | ***************************************************************************/ |
| 51 | 37 | class GContainer : public GBase { |
| 52 | 38 | public: |
| 53 | 39 | // Constructors and destructors |
| 54 | 40 | virtual ~GContainer(void) {} |
| 55 | 41 | |
| 56 | - // Methods | |
| 42 | + // Pure virtual methods | |
| 57 | 43 | virtual int size(void) const = 0; |
| 58 | 44 | virtual bool isempty(void) const = 0; |
| 59 | - virtual void pop(const int& index) = 0; | |
| 45 | + virtual void remove(const int& index) = 0; | |
| 60 | 46 | virtual void reserve(const int& num) = 0; |
| 61 | 47 | }; | ... | ... |
pyext/GEbounds.i
| ... | ... | @@ -54,7 +54,7 @@ public: |
| 54 | 54 | void insert(const GEnergy& emin, const GEnergy& emax); |
| 55 | 55 | void merge(void); |
| 56 | 56 | void merge(const GEnergy& emin, const GEnergy& emax); |
| 57 | - void pop(const int& index); | |
| 57 | + void remove(const int& index); | |
| 58 | 58 | void reserve(const int& num); |
| 59 | 59 | void extend(const GEbounds& ebds); |
| 60 | 60 | void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); | ... | ... |
pyext/GGti.i
| ... | ... | @@ -53,7 +53,7 @@ public: |
| 53 | 53 | void merge(void); |
| 54 | 54 | void merge(const GTime& tstart, const GTime& tstop); |
| 55 | 55 | void reduce(const GTime& tstart, const GTime& tstop); |
| 56 | - void pop(const int& index); | |
| 56 | + void remove(const int& index); | |
| 57 | 57 | void reserve(const int& num); |
| 58 | 58 | void extend(const GGti& gti); |
| 59 | 59 | void load(const std::string& filename, | ... | ... |
pyext/GModels.i
| ... | ... | @@ -66,8 +66,8 @@ public: |
| 66 | 66 | void append(const GModel& model); |
| 67 | 67 | void insert(const int& index, const GModel& model); |
| 68 | 68 | void insert(const std::string& name, const GModel& model); |
| 69 | - void pop(const int& index); | |
| 70 | - void pop(const std::string& name); | |
| 69 | + void remove(const int& index); | |
| 70 | + void remove(const std::string& name); | |
| 71 | 71 | void reserve(const int& num); |
| 72 | 72 | void extend(const GModels& models); |
| 73 | 73 | void set(const int& index, const GModel& model); | ... | ... |
pyext/GOptimizerPars.i
| ... | ... | @@ -47,9 +47,8 @@ public: |
| 47 | 47 | virtual GOptimizerPars* clone(void) const = 0; |
| 48 | 48 | virtual int size(void) const = 0; |
| 49 | 49 | virtual bool isempty(void) const = 0; |
| 50 | - virtual void pop(const int& index) = 0; | |
| 50 | + virtual void remove(const int& index) = 0; | |
| 51 | 51 | virtual void reserve(const int& num) = 0; |
| 52 | - virtual std::string print(void) const = 0; | |
| 53 | 52 | |
| 54 | 53 | // Methods |
| 55 | 54 | virtual int npars(void) const; | ... | ... |
src/model/GModels.cpp
| ... | ... | @@ -41,8 +41,8 @@ |
| 41 | 41 | #define G_ACCESS2 "GModels::operator[](std::string&)" |
| 42 | 42 | #define G_INSERT1 "GModels::insert(int&, GModel&)" |
| 43 | 43 | #define G_INSERT2 "GModels::insert(std::string&, GModel&)" |
| 44 | -#define G_POP1 "GModels::pop(int&)" | |
| 45 | -#define G_POP2 "GModels::pop(std::string&)" | |
| 44 | +#define G_REMOVE1 "GModels::remove(int&)" | |
| 45 | +#define G_REMOVE2 "GModels::remove(std::string&)" | |
| 46 | 46 | #define G_SET1 "GModels::set(int&, GModel&)" |
| 47 | 47 | #define G_SET2 "GModels::set(std::string&, GModel&)" |
| 48 | 48 | #define G_READ "GModels::read(GXml&)" |
| ... | ... | @@ -384,7 +384,7 @@ void GModels::insert(const std::string& name, const GModel& model) |
| 384 | 384 | |
| 385 | 385 | // Throw exception if parameter name was not found |
| 386 | 386 | if (index >= size()) { |
| 387 | - throw GException::model_not_found(G_POP2, name); | |
| 387 | + throw GException::model_not_found(G_INSERT2, name); | |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Make deep copy of model |
| ... | ... | @@ -413,12 +413,12 @@ void GModels::insert(const std::string& name, const GModel& model) |
| 413 | 413 | * |
| 414 | 414 | * Remove model of specified @p index from container. |
| 415 | 415 | ***************************************************************************/ |
| 416 | -void GModels::pop(const int& index) | |
| 416 | +void GModels::remove(const int& index) | |
| 417 | 417 | { |
| 418 | 418 | // Compile option: raise exception if index is out of range |
| 419 | 419 | #if defined(G_RANGE_CHECK) |
| 420 | 420 | if (index < 0 || index >= size()) { |
| 421 | - throw GException::out_of_range(G_POP1, index, 0, size()-1); | |
| 421 | + throw GException::out_of_range(G_REMOVE1, index, 0, size()-1); | |
| 422 | 422 | } |
| 423 | 423 | #endif |
| 424 | 424 | |
| ... | ... | @@ -443,14 +443,14 @@ void GModels::pop(const int& index) |
| 443 | 443 | * |
| 444 | 444 | * Remove model of specified @p name from container. |
| 445 | 445 | ***************************************************************************/ |
| 446 | -void GModels::pop(const std::string& name) | |
| 446 | +void GModels::remove(const std::string& name) | |
| 447 | 447 | { |
| 448 | 448 | // Get parameter index |
| 449 | 449 | int index = get_index(name); |
| 450 | 450 | |
| 451 | 451 | // Throw exception if parameter name was not found |
| 452 | 452 | if (index >= size()) { |
| 453 | - throw GException::model_not_found(G_POP2, name); | |
| 453 | + throw GException::model_not_found(G_REMOVE2, name); | |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | // Erase model component from container | ... | ... |
src/obs/GEbounds.cpp
| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 | #include "GFitsTableDoubleCol.hpp" |
| 40 | 40 | |
| 41 | 41 | /* __ Method name definitions ____________________________________________ */ |
| 42 | -#define G_POP "GEbounds::pop(int&)" | |
| 42 | +#define G_REMOVE "GEbounds::remove(int&)" | |
| 43 | 43 | #define G_EMIN "GEbounds::emin(int&)" |
| 44 | 44 | #define G_EMAX "GEbounds::emax(int&)" |
| 45 | 45 | #define G_EMEAN "GEbounds::emean(int&)" |
| ... | ... | @@ -377,12 +377,12 @@ void GEbounds::merge(const GEnergy& emin, const GEnergy& emax) |
| 377 | 377 | * Note that the method does not actually reduce the memory size but just |
| 378 | 378 | * updates the information on the number of elements in the array. |
| 379 | 379 | ***************************************************************************/ |
| 380 | -void GEbounds::pop(const int& index) | |
| 380 | +void GEbounds::remove(const int& index) | |
| 381 | 381 | { |
| 382 | 382 | #if defined(G_RANGE_CHECK) |
| 383 | 383 | // If index is outside boundary then throw an error |
| 384 | 384 | if (index < 0 || index >= m_num) { |
| 385 | - throw GException::out_of_range(G_POP, index, 0, m_num-1); | |
| 385 | + throw GException::out_of_range(G_REMOVE, index, 0, m_num-1); | |
| 386 | 386 | } |
| 387 | 387 | #endif |
| 388 | 388 | ... | ... |
src/obs/GGti.cpp
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | #include "GFitsTableDoubleCol.hpp" |
| 38 | 38 | |
| 39 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 40 | -#define G_POP "GGti::pop(int&)" | |
| 40 | +#define G_REMOVE "GGti::remove(int&)" | |
| 41 | 41 | #define G_TSTART "GGti::tstart(int&)" |
| 42 | 42 | #define G_TSTOP "GGti::tstop(int&)" |
| 43 | 43 | |
| ... | ... | @@ -421,12 +421,12 @@ void GGti::reduce(const GTime& tstart, const GTime& tstop) |
| 421 | 421 | * Note that the method does not actually reduce the memory size but just |
| 422 | 422 | * updates the information on the number of elements in the array. |
| 423 | 423 | ***************************************************************************/ |
| 424 | -void GGti::pop(const int& index) | |
| 424 | +void GGti::remove(const int& index) | |
| 425 | 425 | { |
| 426 | 426 | #if defined(G_RANGE_CHECK) |
| 427 | 427 | // If index is outside boundary then throw an error |
| 428 | 428 | if (index < 0 || index >= m_num) { |
| 429 | - throw GException::out_of_range(G_POP, index, 0, m_num-1); | |
| 429 | + throw GException::out_of_range(G_REMOVE, index, 0, m_num-1); | |
| 430 | 430 | } |
| 431 | 431 | #endif |
| 432 | 432 | ... | ... |
test/test_GObservation.cpp
| ... | ... | @@ -295,7 +295,7 @@ void TestGObservation::test_ebounds(void) |
| 295 | 295 | test_value(ebds.emax().MeV(), 10.0, 1.0e-10, "Maximum energy should be 10."); |
| 296 | 296 | |
| 297 | 297 | // Remove interval |
| 298 | - ebds.pop(0); | |
| 298 | + ebds.remove(0); | |
| 299 | 299 | test_value(ebds.size(), 0, "GEbounds should have zero size."); |
| 300 | 300 | test_assert(ebds.isempty(), "GEbounds should be empty."); |
| 301 | 301 | test_value(ebds.emin().MeV(), 0.0, 1.0e-10, "Minimum energy should be 0."); |
| ... | ... | @@ -442,7 +442,7 @@ GEbounds ebds; |
| 442 | 442 | test_value(gti.tstop().secs(), 10.0, 1.0e-10, "Stop time should be 10."); |
| 443 | 443 | |
| 444 | 444 | // Remove interval |
| 445 | - gti.pop(0); | |
| 445 | + gti.remove(0); | |
| 446 | 446 | test_value(gti.size(), 0, "GGti should have zero size."); |
| 447 | 447 | test_assert(gti.isempty(), "GGti should be empty."); |
| 448 | 448 | test_value(gti.tstart().secs(), 0.0, 1.0e-10, "Start time should be 0."); | ... | ... |