(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().

This commit is contained in:
frosch
2009-07-20 19:58:33 +00:00
parent a591dc6c8c
commit fec6129cd1
7 changed files with 42 additions and 24 deletions

View File

@@ -366,6 +366,27 @@ public:
*/
inline Vehicle *First() const { return this->first; }
/**
* Get the last vehicle of this vehicle chain.
* @return the last vehicle of the chain.
*/
inline Vehicle *Last()
{
Vehicle *v = this;
while (v->Next() != NULL) v = v->Next();
return v;
}
/**
* Get the last vehicle of this vehicle chain.
* @return the last vehicle of the chain.
*/
inline const Vehicle *Last() const
{
const Vehicle *v = this;
while (v->Next() != NULL) v = v->Next();
return v;
}
/**
* Get the first order of the vehicles order list.
@@ -537,6 +558,18 @@ struct SpecializedVehicle : public Vehicle {
*/
FORCEINLINE T *First() const { return (T *)this->Vehicle::First(); }
/**
* Get the last vehicle in the chain
* @return last vehicle in the chain
*/
FORCEINLINE T *Last() { return (T *)this->Vehicle::Last(); }
/**
* Get the last vehicle in the chain
* @return last vehicle in the chain
*/
FORCEINLINE const T *Last() const { return (const T *)this->Vehicle::Last(); }
/**
* Get next vehicle in the chain
* @return next vehicle in the chain