相关疑难解决方法(0)

估计C++ 11中剩下的时间

我正在编写一个进度条类,每个n刻度都会输出一个更新的进度条std::ostream:

class progress_bar
{
public:
  progress_bar(uint64_t ticks)
    : _total_ticks(ticks), ticks_occured(0),
      _begin(std::chrono::steady_clock::now())
  ...
  void tick()
  {
    // test to see if enough progress has elapsed
    //  to warrant updating the progress bar
    //  that way we aren't wasting resources printing
    //  something that hasn't changed
    if (/* should we update */)
    {
      ...
    }
  }
private:
  std::uint64_t _total_ticks;
  std::uint64_t _ticks_occurred;
  std::chrono::steady_clock::time_point _begin;
  ...
}
Run Code Online (Sandbox Code Playgroud)

我还想输出剩余的时间.我在另一个问题上找到了一个公式,说明剩余的时间是(变量名称已更改为适合我的班级):

time_left = (time_taken / _total_ticks) * (_total_ticks - _ticks_occured)

我想填补了我的课的部分是 …

c++ algorithm c++11

6
推荐指数
1
解决办法
3069
查看次数

标签 统计

algorithm ×1

c++ ×1

c++11 ×1