PIVector getRange removeWhere
This commit is contained in:
@@ -283,6 +283,12 @@ public:
|
|||||||
inline T * data(size_t index = 0) {return &(piv_data[index]);}
|
inline T * data(size_t index = 0) {return &(piv_data[index]);}
|
||||||
inline const T * data(size_t index = 0) const {return &(piv_data[index]);}
|
inline const T * data(size_t index = 0) const {return &(piv_data[index]);}
|
||||||
|
|
||||||
|
PIVector<T> getRange(size_t index, size_t count) const {
|
||||||
|
if (index >= piv_size || count == 0) return PIVector<T>();
|
||||||
|
if (index + count > piv_size) count = piv_size - index;
|
||||||
|
return PIVector(&(piv_data[index]), count);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T1 = T, typename std::enable_if<
|
template<typename T1 = T, typename std::enable_if<
|
||||||
!std::is_trivially_copyable<T1>::value
|
!std::is_trivially_copyable<T1>::value
|
||||||
, int>::type = 0>
|
, int>::type = 0>
|
||||||
@@ -462,7 +468,6 @@ public:
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PIVector<T> & removeAll(const T & e) {
|
inline PIVector<T> & removeAll(const T & e) {
|
||||||
for (ssize_t i = 0; i < ssize_t(piv_size); ++i) {
|
for (ssize_t i = 0; i < ssize_t(piv_size); ++i) {
|
||||||
if (piv_data[i] == e) {
|
if (piv_data[i] == e) {
|
||||||
@@ -472,6 +477,15 @@ public:
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
inline PIVector<T> & removeWhere(std::function<bool(const T & e)> test) {
|
||||||
|
for (ssize_t i = 0; i < ssize_t(piv_size); ++i) {
|
||||||
|
if (test(piv_data[i])) {
|
||||||
|
remove(i);
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
inline PIVector<T> & push_back(const T & e) {
|
inline PIVector<T> & push_back(const T & e) {
|
||||||
alloc(piv_size + 1);
|
alloc(piv_size + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user