OpenSiv3D
OpenSiv3D copied to clipboard
Arrayクラスにpartition関数の実装
追加する機能の内容 | Describe the solution you'd like 指定された条件式に一致する要素としない要素で配列を区分けする。
その機能の追加によって解決する問題 | Is your feature request related to a problem? Please describe. 配列内要素の区分け処理
備考 | Additional context
template<class Fty, std::enable_if_t<std::invocable_r_v<bool, Fty,const Ty&>, int> = 0>
decltype(auto) partition(Fty _func)
{
return std::ranges::partition(m_container, _func);
}
開発中の v0.6.6 に Array::partition() および Array::stable_partition() を実装しました。
ご提案ありがとうございました。
# include <Siv3D.hpp> // OpenSiv3D v0.6.6
void Main()
{
{
Array<int32> v = { 0, 1, 2, 3, 4, 5, 10 };
v.partition(IsEven);
Print << v;
}
{
Array<int32> v = { 0, 1, 2, 3, 4, 5, 10 };
v.stable_partition(IsEven);
Print << v;
}
while (System::Update())
{
}
}