grade_school: iteration 1
This commit is contained in:
parent
6055b23a3a
commit
a9b7e33d89
2 changed files with 66 additions and 0 deletions
35
cpp/grade-school/grade_school.cpp
Normal file
35
cpp/grade-school/grade_school.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "grade_school.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace grade_school {
|
||||
|
||||
using namespace std;
|
||||
|
||||
static const grade_t empty_grade = grade_t();
|
||||
|
||||
|
||||
school::school()
|
||||
{
|
||||
}
|
||||
|
||||
void school::add(const name_t &name, grade_number_t grade_number)
|
||||
{
|
||||
grade_t &grade = roster_[grade_number];
|
||||
grade.insert(upper_bound(grade.begin(), grade.end(), name), name);
|
||||
}
|
||||
|
||||
const grade_t &school::grade(grade_number_t number) const
|
||||
{
|
||||
if (roster_.count(number))
|
||||
return roster_.at(number);
|
||||
else
|
||||
return empty_grade;
|
||||
}
|
||||
|
||||
const roster_t &school::roster() const
|
||||
{
|
||||
return roster_;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue