From 1243cb834e83c350dbee887d096e551406ec31e2 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 13 Jun 2009 22:20:39 +0200 Subject: adding documentation --- ue5/array.hpp | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 178 insertions(+), 3 deletions(-) (limited to 'ue5/array.hpp') diff --git a/ue5/array.hpp b/ue5/array.hpp index 0acd37d..a78ff56 100644 --- a/ue5/array.hpp +++ b/ue5/array.hpp @@ -1,3 +1,10 @@ +/** + * @module array + * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) + * @brief Class template array + * @date 13.06.2009 + */ + #ifndef ARRAY_H #define ARRAY_H @@ -10,72 +17,208 @@ namespace Ti { + /** + * @class array + * + * Array defines a class template for storing fixed-size sequences of objects. + */ template struct array { + /** lvalue of T */ typedef T& reference; + /** constant lvalue of T */ typedef const T& const_reference; + /** iterator type whose value type is T */ typedef T* iterator; + /** constant iterator type whose value type is T */ typedef const T* const_iterator; + /** unsigned integral type */ typedef std::size_t size_type; + /* we don't suppport zero-sized arrays */ static_assert(N != 0, "array not allowed"); + /** + * @method fill + * @brief Fills container with elements of u + * @param u object to fill array with + * @return return N + * @globalvars none + * @exception none + * @pre requires CopyAssignable void fill(const T& u) + * @post none + */ void fill(const T& u) { std::fill_n(begin(), N, u); } - void swap(array & other) + /** + * @method swap + * @brief Exchanges the contents of *this and other. + * @param other object to swap with + * @return - + * @globalvars none + * @exception none + * @pre none + * @post none + */ + void swap(array& other) { std::swap_ranges(begin(), end(), other.begin()); } + /** + * @method begin + * @brief Get an iterator referring to the first element in the container + * @param - + * @return iterator referring to the first element in the container. + * @globalvars none + * @exception none + * @pre none + * @post none + */ iterator begin() { return m_data; } + /** + * @method begin + * @brief Get a constant iterator referring to the first element in the + * container + * @param - + * @return constant iterator referring to the first element in the container. + * @globalvars none + * @exception none + * @pre none + * @post none + */ const_iterator begin() const { return m_data; } + /** + * @method end + * @brief Get an iterator which is the past-the-end value for the container. + * @param - + * @return iterator which is the past-the-end value for the container + * @globalvars none + * @exception none + * @pre none + * @post none + */ iterator end() { return m_data + N; } + /** + * @method end + * @brief Get a constant iterator which is the past-the-end value for the + * container. + * @param - + * @return constant iterator which is the past-the-end value for the container + * @globalvars none + * @exception none + * @pre none + * @post none + */ const_iterator end() const { return m_data + N; } + /** + * @method size + * @brief Get number of elements in the container + * @param - + * @return return N + * @globalvars none + * @exception none + * @pre none + * @post none + */ size_type size() const { return N; } + /** + * @method max_size + * @brief Get maximal number of elements which fit into the container + * @param - + * @return return N + * @globalvars none + * @exception none + * @pre none + * @post none + */ size_type max_size() const { return N; } + /** + * @method empty + * @brief Check if container is empty + * @param - + * @return always false + * @globalvars none + * @exception none + * @pre none + * @post none + */ bool empty() const { return false; /* size() == 0 */ } + /** + * @method operator[] + * @brief operator [] + * @param n position of an element in the array + * @return reference to the element at position n in the container + * @globalvars none + * @exception none + * @pre none + * @post none + */ reference operator[](size_type n) { return m_data[n]; } + /** + * @method operator[] + * @brief operator [] + * @param n position of an element in the array + * @return constant reference to the element at position n in the container + * @globalvars none + * @exception none + * @pre none + * @post none + */ const_reference operator[](size_type n) const { return m_data[n]; } + /** + * @method at + * @brief Get reference to the element at position n + * @param n position of an element in the array + * @return reference to the element at position n in the container. + * The difference between this member function and member operator + * function operator[] is that at signals if the requested + * position is out of range by throwing an out_of_range exception. + * @globalvars none + * @exception out_of_range + * @pre none + * @post none + */ reference at(size_type n) { if (n >= N) @@ -83,6 +226,19 @@ namespace Ti return m_data[n]; } + /** + * @method at + * @brief Get constant reference to the element at position n + * @param n position of an element in the array + * @return constant reference to the element at position n in the container. + * The difference between this member function and member operator + * function operator[] is that at signals if the requested + * position is out of range by throwing an out_of_range exception. + * @globalvars none + * @exception out_of_range + * @pre none + * @post none + */ const_reference at(size_type n) const { if (n >= N) @@ -90,22 +246,41 @@ namespace Ti return m_data[n]; } + /** + * @method data + * @brief Check if container is empty + * @param - + * @return returns enclosed array + * @globalvars none + * @exception none + * @pre none + * @post none + */ T* data() { return m_data; } private: + /** enclosed array */ T m_data[N]; }; - /* std::move returns lvalue as rvalue */ + /** + * @method make_array + * @brief Get an rvalue of an empty array + * @param none + * @return rvalue of an empty array + * @globalvars none + * @exception none + * @pre none + * @post none + */ template array&& make_array() { return std::move(array()); } - } // namespace #endif -- cgit v1.2.3