forked from mirror/OpenTTD
Codechange: Replaced SmallVector::[Begin|End]() with std alternatives
This commit is contained in:
@@ -31,10 +31,7 @@
|
||||
*/
|
||||
/* static */ void PoolBase::Clean(PoolType pt)
|
||||
{
|
||||
PoolVector *pools = PoolBase::GetPools();
|
||||
PoolBase **end = pools->End();
|
||||
for (PoolBase **ppool = pools->Begin(); ppool != end; ppool++) {
|
||||
PoolBase *pool = *ppool;
|
||||
for (PoolBase *pool : *PoolBase::GetPools()) {
|
||||
if (pool->type & pt) pool->CleanPool();
|
||||
}
|
||||
}
|
||||
|
@@ -55,12 +55,13 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
* @param key key to find
|
||||
* @return &Pair(key, data) if found, this->End() if not
|
||||
*/
|
||||
inline const Pair *Find(const T &key) const
|
||||
inline typename std::vector<Pair>::const_iterator Find(const T &key) const
|
||||
{
|
||||
for (uint i = 0; i < std::vector<Pair>::size(); i++) {
|
||||
if (key == std::vector<Pair>::operator[](i).first) return &std::vector<Pair>::operator[](i);
|
||||
typename std::vector<Pair>::const_iterator it;
|
||||
for (it = std::vector<Pair>::begin(); it != std::vector<Pair>::end(); it++) {
|
||||
if (key == it->first) return it;
|
||||
}
|
||||
return this->End();
|
||||
return it;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +115,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
*/
|
||||
inline void Erase(Pair *pair)
|
||||
{
|
||||
assert(pair >= this->Begin() && pair < this->End());
|
||||
assert(pair >= std::vector<Pair>::data() && pair < this->End());
|
||||
auto distance = pair - std::vector<Pair>::data();
|
||||
std::vector<Pair>::erase(std::vector<Pair>::begin() + distance);
|
||||
}
|
||||
@@ -166,7 +167,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
|
||||
|
||||
inline void SortByKey()
|
||||
{
|
||||
QSortT(this->Begin(), std::vector<Pair>::size(), KeySorter);
|
||||
QSortT(std::vector<Pair>::data(), std::vector<Pair>::size(), KeySorter);
|
||||
}
|
||||
|
||||
static int CDECL KeySorter(const Pair *a, const Pair *b)
|
||||
|
@@ -83,46 +83,6 @@ public:
|
||||
}
|
||||
|
||||
~SmallVector() = default;
|
||||
|
||||
/**
|
||||
* Get the pointer to the first item (const)
|
||||
*
|
||||
* @return the pointer to the first item
|
||||
*/
|
||||
inline const T *Begin() const
|
||||
{
|
||||
return std::vector<T>::data();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer to the first item
|
||||
*
|
||||
* @return the pointer to the first item
|
||||
*/
|
||||
inline T *Begin()
|
||||
{
|
||||
return std::vector<T>::data();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer behind the last valid item (const)
|
||||
*
|
||||
* @return the pointer behind the last valid item
|
||||
*/
|
||||
inline const T *End() const
|
||||
{
|
||||
return std::vector<T>::data() + std::vector<T>::size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer behind the last valid item
|
||||
*
|
||||
* @return the pointer behind the last valid item
|
||||
*/
|
||||
inline T *End()
|
||||
{
|
||||
return std::vector<T>::data() + std::vector<T>::size();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user