diff --git a/include/momo/Array.h b/include/momo/Array.h index ac57fd439..b0dc005eb 100644 --- a/include/momo/Array.h +++ b/include/momo/Array.h @@ -934,11 +934,11 @@ class Array ArrayShifter::Remove(*this, index, count); } - template - internal::EnableIf::value, - size_t> Remove(const Predicate& pred) + template + internal::EnableIf::value, + size_t> Remove(const ItemFilter& itemFilter) { - return ArrayShifter::Remove(*this, pred); + return ArrayShifter::Remove(*this, itemFilter); } template> diff --git a/include/momo/ArrayUtility.h b/include/momo/ArrayUtility.h index 7ad17ed12..64a387a35 100644 --- a/include/momo/ArrayUtility.h +++ b/include/momo/ArrayUtility.h @@ -271,17 +271,17 @@ namespace internal array.RemoveBack(count); } - template - static size_t Remove(Array& array, const Predicate& pred) + template + static size_t Remove(Array& array, const ItemFilter& itemFilter) { size_t initCount = array.GetCount(); size_t newCount = 0; - while (newCount < initCount && !pred(static_cast(array[newCount]))) + while (newCount < initCount && !itemFilter(static_cast(array[newCount]))) ++newCount; MemManager& memManager = array.GetMemManager(); for (size_t i = newCount + 1; i < initCount; ++i) { - if (pred(static_cast(array[i]))) + if (itemFilter(static_cast(array[i]))) continue; ItemTraits::Assign(memManager, std::move(array[i]), array[newCount]); ++newCount; diff --git a/include/momo/MemPool.h b/include/momo/MemPool.h index 05ebdaca4..6100b3ff1 100644 --- a/include/momo/MemPool.h +++ b/include/momo/MemPool.h @@ -325,8 +325,8 @@ class MemPool : private TParams, private internal::MemManagerWrapper // bool Predicate(void*) - void DeallocateIf(const Predicate& pred) + template // bool BlockFilter(void*) + void DeallocateIf(const BlockFilter& blockFilter) { MOMO_EXTRA_CHECK(CanDeallocateAll()); if (pvUseCache()) @@ -337,7 +337,7 @@ class MemPool : private TParams, private internal::MemManagerWrapper - void pvDeleteBlocks(Byte* buffer, const Predicate& pred) + template + void pvDeleteBlocks(Byte* buffer, const BlockFilter& blockFilter) { int8_t firstBlockIndex = pvGetFirstBlockIndex(buffer); uint8_t freeBlockBits[16] = {}; @@ -671,7 +671,7 @@ class MemPool : private TParams, private internal::MemManagerWrapper(i); Byte* block = pvGetBlock(buffer, blockIndex); - if (!pred(static_cast(block))) + if (!blockFilter(static_cast(block))) continue; pvDeleteBlock(block, buffer, blockIndex); --mAllocCount; diff --git a/include/momo/SegmentedArray.h b/include/momo/SegmentedArray.h index d9c830824..9378e98bc 100644 --- a/include/momo/SegmentedArray.h +++ b/include/momo/SegmentedArray.h @@ -587,11 +587,11 @@ class SegmentedArray ArrayShifter::Remove(*this, index, count); } - template - internal::EnableIf::value, - size_t> Remove(const Predicate& pred) + template + internal::EnableIf::value, + size_t> Remove(const ItemFilter& itemFilter) { - return ArrayShifter::Remove(*this, pred); + return ArrayShifter::Remove(*this, itemFilter); } template> diff --git a/include/momo/stdish/vector.h b/include/momo/stdish/vector.h index abe178af8..49b092d27 100644 --- a/include/momo/stdish/vector.h +++ b/include/momo/stdish/vector.h @@ -425,15 +425,15 @@ class vector template friend size_type erase(vector& cont, const ValueArg& valueArg) { - auto pred = [&valueArg] (const value_type& value) + auto valueFilter = [&valueArg] (const value_type& value) { return value == valueArg; }; - return cont.mArray.Remove(pred); + return cont.mArray.Remove(valueFilter); } - template - friend size_type erase_if(vector& cont, const Predicate& pred) + template + friend size_type erase_if(vector& cont, const ValueFilter& valueFilter) { - return cont.mArray.Remove(pred); + return cont.mArray.Remove(valueFilter); } void assign(size_type count, const value_type& value) diff --git a/test/sources/SimpleMemPoolTester.cpp b/test/sources/SimpleMemPoolTester.cpp index 3d15a979a..015239d87 100644 --- a/test/sources/SimpleMemPoolTester.cpp +++ b/test/sources/SimpleMemPoolTester.cpp @@ -160,7 +160,7 @@ class SimpleMemPoolTester } assert(memPool.GetAllocateCount() == lim2); - auto pred = [&blocks, blockSize, lim1] (void* block) + auto blockFilter = [&blocks, blockSize, lim1] (void* block) { auto begin = blocks.GetBegin(); auto mid = begin + lim1; @@ -172,7 +172,7 @@ class SimpleMemPoolTester std::memset(block, 2, blockSize); return res; }; - memPool.DeallocateIf(pred); + memPool.DeallocateIf(blockFilter); blocks.SetCount(lim1); assert(memPool.GetAllocateCount() == lim1); } diff --git a/test/sources/SimpleTreeTester.cpp b/test/sources/SimpleTreeTester.cpp index 6b33d0852..7b7774be6 100644 --- a/test/sources/SimpleTreeTester.cpp +++ b/test/sources/SimpleTreeTester.cpp @@ -121,7 +121,7 @@ class SimpleTreeTester { typedef momo::TreeMap TreeMap; typedef TreeMap::ConstIterator::Reference Reference; - auto pred = [] (Reference ref1, Reference ref2) + auto equalFunc = [] (Reference ref1, Reference ref2) { return ref1.key == ref2.key && ref1.value == ref2.value; }; std::string s1 = "s1"; @@ -190,7 +190,7 @@ class SimpleTreeTester assert(ep.IsEmpty()); map.Insert(map2.GetBegin(), std::next(map2.GetBegin())); - assert(std::equal(map.GetBegin(), map.GetEnd(), map2.GetBegin(), pred)); + assert(std::equal(map.GetBegin(), map.GetEnd(), map2.GetBegin(), equalFunc)); map.Clear(); assert(map.IsEmpty()); @@ -199,7 +199,7 @@ class SimpleTreeTester map.Add(map.GetUpperBound("s2"), s2, "s2"); map.Add(map.GetLowerBound(s3), "s3", s3); map.Add(map.GetUpperBound(s4), "s4", "s4"); - assert(std::equal(map.GetBegin(), map.GetEnd(), map2.GetBegin(), pred)); + assert(std::equal(map.GetBegin(), map.GetEnd(), map2.GetBegin(), equalFunc)); } static void TestTemplAll()