diff options
Diffstat (limited to 'lout/misc.hh')
-rw-r--r-- | lout/misc.hh | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/lout/misc.hh b/lout/misc.hh index 2a8584eb..05b87602 100644 --- a/lout/misc.hh +++ b/lout/misc.hh @@ -7,13 +7,13 @@ #include <string.h> #include <assert.h> +namespace lout { + /** * \brief Miscellaneous stuff, which does not fit anywhere else. * * Actually, the other parts, beginning with ::object, depend on this. */ -namespace lout { - namespace misc { template <class T> inline T min (T a, T b) { return a < b ? a : b; } @@ -201,6 +201,38 @@ public: } /** + * \brief Return the reference of the first element (convenience method). + */ + inline T* getFirstRef () { + assert (this->num > 0); + return this->array; + } + + /** + * \brief Return the first element, explicitly. + */ + inline T getFirst () { + assert (this->num > 0); + return this->array[0]; + } + + /** + * \brief Return the reference of the last element (convenience method). + */ + inline T* getLastRef () { + assert (this->num > 0); + return this->array + this->num - 1; + } + + /** + * \brief Return the last element, explicitly. + */ + inline T getLast () { + assert (this->num > 0); + return this->array[this->num - 1]; + } + + /** * \brief Store an object in the vector. * * Unlike in container::untyped::Vector and container::typed::Vector, |