diff options
Diffstat (limited to 'ue5/mean_mark.hpp')
| -rw-r--r-- | ue5/mean_mark.hpp | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/ue5/mean_mark.hpp b/ue5/mean_mark.hpp index e07aedc..614a671 100644 --- a/ue5/mean_mark.hpp +++ b/ue5/mean_mark.hpp | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | /** | ||
| 2 | * @module mean_mark | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Templates for mean_mark, mean_mark_student, remove_greater | ||
| 5 | * @date 13.06.2009 | ||
| 6 | */ | ||
| 7 | |||
| 1 | #ifndef MEAN_MARK_H | 8 | #ifndef MEAN_MARK_H |
| 2 | #define MEAN_MARK_H | 9 | #define MEAN_MARK_H |
| 3 | 10 | ||
| @@ -9,7 +16,18 @@ | |||
| 9 | 16 | ||
| 10 | namespace Ti | 17 | namespace Ti |
| 11 | { | 18 | { |
| 12 | 19 | /** | |
| 20 | * @method mean_mark | ||
| 21 | * @brief computes mean mark in the range [first,last) | ||
| 22 | * @param first forward iterator to the initial positions in a sequence | ||
| 23 | * @param last forward iterator to the final positions in a sequence | ||
| 24 | * @return computed mean mark | ||
| 25 | * @globalvars none | ||
| 26 | * @exception none | ||
| 27 | * @pre all objects in the sequence must have a method mark returning a type | ||
| 28 | * convertible to double | ||
| 29 | * @post none | ||
| 30 | */ | ||
| 13 | template <typename Iter> | 31 | template <typename Iter> |
| 14 | double mean_mark(Iter first, Iter last) | 32 | double mean_mark(Iter first, Iter last) |
| 15 | { | 33 | { |
| @@ -23,6 +41,19 @@ namespace Ti | |||
| 23 | return (count == 0) ? 0 : result / count; | 41 | return (count == 0) ? 0 : result / count; |
| 24 | } | 42 | } |
| 25 | 43 | ||
| 44 | /** | ||
| 45 | * @method mean_mark_student | ||
| 46 | * @brief computes mean mark of objects of type Student in the range [first,last) | ||
| 47 | * (using RTTI) | ||
| 48 | * @param first forward iterator to the initial positions in a sequence | ||
| 49 | * @param last forward iterator to the final positions in a sequence | ||
| 50 | * @return computed mean mark of objects of type Student | ||
| 51 | * @globalvars none | ||
| 52 | * @exception none | ||
| 53 | * @pre All objects in the sequence must have a method mark returning a type | ||
| 54 | * convertible to double. And type Stundent must exist | ||
| 55 | * @post none | ||
| 56 | */ | ||
| 26 | template <typename Iter> | 57 | template <typename Iter> |
| 27 | double mean_mark_student(Iter first, Iter last) | 58 | double mean_mark_student(Iter first, Iter last) |
| 28 | { | 59 | { |
| @@ -41,6 +72,23 @@ namespace Ti | |||
| 41 | return (count == 0) ? 0 : result / count; | 72 | return (count == 0) ? 0 : result / count; |
| 42 | } | 73 | } |
| 43 | 74 | ||
| 75 | /** | ||
| 76 | * @method remove_greater | ||
| 77 | * @brief Removes from the range [first,last) the elements with a mark greater | ||
| 78 | * than mark and returns an iterator to the new end of the range, | ||
| 79 | * which now includes only elements with a mark less than mark. | ||
| 80 | * @param first forward iterator to the initial positions in a sequence | ||
| 81 | * @param last forward iterator to the final positions in a sequence | ||
| 82 | * @param mark maximal value for mark to keep | ||
| 83 | * @return A forward iterator pointing to the new end of the sequence, | ||
| 84 | * which now includes all the elements with a mark less than mark. | ||
| 85 | * @globalvars none | ||
| 86 | * @exception none | ||
| 87 | * @pre All objects in the sequence must have a method mark returning a type | ||
| 88 | * convertible to double. | ||
| 89 | * @post This function does not alter the elements past the new end, | ||
| 90 | * which keep their old values and are still accessible. | ||
| 91 | */ | ||
| 44 | template <class ForwardIterator> | 92 | template <class ForwardIterator> |
| 45 | ForwardIterator remove_greater (ForwardIterator first, ForwardIterator last, int mark) | 93 | ForwardIterator remove_greater (ForwardIterator first, ForwardIterator last, int mark) |
| 46 | { | 94 | { |
| @@ -55,7 +103,6 @@ namespace Ti | |||
| 55 | } | 103 | } |
| 56 | return result; | 104 | return result; |
| 57 | } | 105 | } |
| 58 | |||
| 59 | } | 106 | } |
| 60 | 107 | ||
| 61 | #endif | 108 | #endif |
