Skip to content

Commit

Permalink
Add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aliasgharafzalabadi committed Feb 7, 2021
1 parent 0199398 commit 036bc9e
Showing 1 changed file with 70 additions and 2 deletions.
72 changes: 70 additions & 2 deletions Afzalabadi/Student/classes/student.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class StudentModel
};

typedef list<StudentModel>::iterator StudentIterator;

typedef list<StudentModel>::reverse_iterator RStudentIterator;

class Student
{
Expand Down Expand Up @@ -62,7 +62,8 @@ class Student
Student* filter(Field filteredField);
Student* sort(Field sortField, SortMode sortMode = SortMode :: Asc);
Student* limit(size_t count);

Student* first(bool filteredData = false);
Student* last(bool filteredData = false);



Expand Down Expand Up @@ -386,7 +387,74 @@ Student* Student::limit(size_t count)
this->limitCount = count;
return this;
}
Student* Student::first(bool filteredData)
{
if(filteredData)
{
for (StudentIterator it = this->students.begin(); it != this->students.end(); it++)
{
if(it -> filtered)
{
this->studentModel = *it;
break;
}
}
}
else
{
this->studentModel = this->students.front() ;
}
return this;

}

Student* Student::last(bool filteredData = false)
{
if(filteredData)
{
for(RStudentIterator it = this->students.rbegin(); it !=this->students.rend();it++)

if(it -> filtered)
{
this->studentModel = *it;
break;
}
else
{
this->studentModel = this->students.back() ;
}

}
return this;
}






























//https://en.cppreference.com/w/cpp/links/libs

0 comments on commit 036bc9e

Please sign in to comment.