1 Star 0 Fork 0

ly-code/concurrentqueue

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
array_tools.h 937 Bytes
一键复制 编辑 原始数据 按行查看 历史
pf 提交于 2020-11-08 01:46 +08:00 . Added dlib::pipe<> to the benchmark
// Copyright (C) 2013 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ARRAY_tOOLS_H_
#define DLIB_ARRAY_tOOLS_H_
#include "../assert.h"
#include "array_tools_abstract.h"
namespace dlib
{
template <typename T>
void split_array (
T& a,
T& b,
double frac
)
{
// make sure requires clause is not broken
DLIB_ASSERT(0 <= frac && frac <= 1,
"\t void split_array()"
<< "\n\t frac must be between 0 and 1."
<< "\n\t frac: " << frac
);
const unsigned long asize = static_cast<unsigned long>(a.size()*frac);
const unsigned long bsize = a.size()-asize;
b.resize(bsize);
for (unsigned long i = 0; i < b.size(); ++i)
{
swap(b[i], a[i+asize]);
}
a.resize(asize);
}
}
#endif // DLIB_ARRAY_tOOLS_H_
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ly-code/concurrentqueue.git
git@gitee.com:ly-code/concurrentqueue.git
ly-code
concurrentqueue
concurrentqueue
master

搜索帮助