{"id":1055,"url":"https://patchwork.libcamera.org/api/patches/1055/?format=json","web_url":"https://patchwork.libcamera.org/patch/1055/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190418141437.14014-9-laurent.pinchart@ideasonboard.com>","date":"2019-04-18T14:14:32","name":"[libcamera-devel,v3,08/13] libcamera: utils: Add set_overlap() function","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b620aae046db7f92270cd77e3647b4c05a4ffb49","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1055/mbox/","series":[{"id":256,"url":"https://patchwork.libcamera.org/api/series/256/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=256","date":"2019-04-18T14:14:24","name":"Rockchip ISP pipeline handler","version":3,"mbox":"https://patchwork.libcamera.org/series/256/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1055/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1055/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BAA2C60DC6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 16:14:57 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F469333\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 16:14:57 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555596897;\n\tbh=bWh0/QPbU0r4kITQv6ooxGQ4yRXLQO/1DRYUJh5+T0Q=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=AK4LzH7qU0kgLhlEGKPMIoneUXqIIYyYlCTkClswnuVgXoEVh3/qRCO/r6tIRLfFE\n\t/6x2lzt11bNhHftRPXnkmgm8kvGa9B1irZZA/UBR36LB67TfmsTKBRU4PBNjMCAXBQ\n\tkHXjt7EjEYLPkND78ncE6N62p9DzJsCZo5VhaZig=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 18 Apr 2019 17:14:32 +0300","Message-Id":"<20190418141437.14014-9-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190418141437.14014-1-laurent.pinchart@ideasonboard.com>","References":"<20190418141437.14014-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 08/13] libcamera: utils: Add\n\tset_overlap() function","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 18 Apr 2019 14:14:58 -0000"},"content":"The new set_overlap() function counts the number of overlapping elements\nin the intersection of two sorted ranges defined by their beginning and\nending iterators.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/utils.h | 19 +++++++++++++++++++\n src/libcamera/utils.cpp       | 12 ++++++++++++\n 2 files changed, 31 insertions(+)","diff":"diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex 79038a96feab..97bd470a45b0 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -26,6 +26,25 @@ std::unique_ptr<T> make_unique(Args&&... args)\n \n char *secure_getenv(const char *name);\n \n+template<class InputIt1, class InputIt2>\n+unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n+\t\t\t InputIt2 first2, InputIt2 last2)\n+{\n+\tunsigned int count = 0;\n+\n+\twhile (first1 != last1 && first2 != last2) {\n+\t\tif (*first1 < *first2) {\n+\t\t\t++first1;\n+\t\t} else {\n+\t\t\tif (!(*first2 < *first1))\n+\t\t\t\tcount++;\n+\t\t\t++first2;\n+\t\t}\n+\t}\n+\n+\treturn count;\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex cd0fd7614cc7..e38f32684bb1 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -68,6 +68,18 @@ char *secure_getenv(const char *name)\n  * \\brief Constructs an object of type T and wraps it in a std::unique_ptr.\n  */\n \n+/**\n+ * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n+ *\t\t\t\t     InputIt2 first2, InputIt2 last2)\n+ * \\brief Count the number of elements in the intersection of two ranges\n+ *\n+ * Count the number of elements in the intersection of the sorted ranges [\\a\n+ * first1, \\a last1) and [\\a first1, \\a last2). Elements are compared using\n+ * operator< and the ranges must be sorted with respect to the same.\n+ *\n+ * \\return The number of elements in the intersection of the two ranges\n+ */\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v3","08/13"]}