mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(array): add TSBaseArray::Top
This commit is contained in:
parent
6d1d2eefd9
commit
c42164ea5f
2 changed files with 33 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ class TSBaseArray {
|
|||
void Clear();
|
||||
T* Ptr();
|
||||
const T* Ptr() const;
|
||||
T* Top();
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
|
@ -77,4 +78,13 @@ const T* TSBaseArray<T>::Ptr() const {
|
|||
return this->m_data;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T* TSBaseArray<T>::Top() {
|
||||
if (this->m_count == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &this->m_data[this->m_count - 1];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue