コード例 #1
0
 void emplace_front(Args&&... args) {
     const bool need_reinit = (min_ == data_.cend());
     data_.emplace_front(std::forward<Args>(args)...);
     if (need_reinit || data_.front() < *min_) {
         min_ = pointer_to_first();
     }
 }
コード例 #2
0
static void labelNeighbours(const cv::Mat &image, const int currentLabel,
                            Eigen::RowMatrixXi &labeledImage,
                            std::list<std::pair<int, int>> &toLabel) {

  if (toLabel.empty())
    return;

  int yOffset, xOffset;
  std::tie(yOffset, xOffset) = toLabel.front();
  toLabel.pop_front();

  for (int j = -1; j <= 1; ++j) {
    for (int i = -1; i <= 1; ++i) {
      if (j + yOffset < 0 || j + yOffset >= labeledImage.rows())
        continue;
      if (i + xOffset < 0 || i + xOffset >= labeledImage.cols())
        continue;
      if (image.at<uchar>(j + yOffset, i + xOffset) != 255 &&
          labeledImage(j + yOffset, i + xOffset) == 0) {
        labeledImage(j + yOffset, i + xOffset) = currentLabel;
        toLabel.emplace_front(j + yOffset, i + xOffset);
      }
    }
  }

  labelNeighbours(image, currentLabel, labeledImage, toLabel);
}
コード例 #3
0
ファイル: Tape.hpp プロジェクト: jellysheep/mutablecode
		void moveLeft()
		{
			if(current != data.begin())
				--current;
			else
			{
				data.emplace_front();
				current = data.begin();
			}
		}
コード例 #4
0
ファイル: ofxWidget.cpp プロジェクト: tgfrerer/ofxWidget
// ----------------------------------------------------------------------
// widgets may only be created through this factory function
shared_ptr<ofxWidget> ofxWidget::make(const ofRectangle& rect_) {
	// register for mouse events
	// this happens only when the first widget gets initialised.
	static auto onlyResponder = make_shared<WidgetEventResponder>();

	auto widget = shared_ptr<ofxWidget>(new ofxWidget());
	widget->mRect = rect_;
	widget->mThis = widget; // widget keeps weak store to self - will this make it leak?
	// it should not, since we're creating the widget using new(), and not make_shared

	sAllWidgets.emplace_front(widget);  // store a weak pointer to the new object in our list
	ofxWidget::bVisibleListDirty = true;
	return std::move(widget);
}
コード例 #5
0
 void append(K const& key, VV&& value) {
     std::unique_lock<std::mutex> lock(mutex);
     
     if (map.find(key) != map.end()) {
         map[key]->second = std::forward<VV>(value);
         lst.splice(lst.begin(), lst, map[key]);
     } else {
         lst.emplace_front(key, std::forward<VV>(value));
     }
     
     map[key] = lst.begin();
     
     if (lst.size() > max_size) {
         map.erase(lst.back().first);
         lst.pop_back();
     }
 }
コード例 #6
0
void good_emplace_front_list1(std::list<int> &L, int n) {
  auto i0 = L.cbegin(), i1 = L.cend();
  L.emplace_front(n);
  *i0; // no-warning
  --i1; // no-warning
}
コード例 #7
0
		template<class T, class... Ts>void init_impl(T arg, Ts... args)
		{
			init_impl(args...);
			sentence.emplace_front(arg);
		}