[{"id":1418,"web_url":"https://patchwork.libcamera.org/comment/1418/","msgid":"<20190416225901.GH28515@bigcity.dyn.berto.se>","date":"2019-04-16T22:59:01","subject":"Re: [libcamera-devel] [PATCH v2 08/13] libcamera: utils: Add\n\tset_overlap() function","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2019-04-17 01:08:34 +0300, Laurent Pinchart wrote:\n> The new set_overlap() function counts the number of overlapping elements\n> in the intersection of two sorted ranges defined by their beginning and\n> ending iterators.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/utils.h | 19 +++++++++++++++++++\n>  src/libcamera/utils.cpp       | 12 ++++++++++++\n>  2 files changed, 31 insertions(+)\n> \n> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> index 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 */\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8044860004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 00:59:03 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id k8so20640740lja.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2019 15:59:03 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tq5sm9464875lff.30.2019.04.16.15.59.01\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 16 Apr 2019 15:59:02 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=XhhUci6NIj8QjiiV9JcEPodspuV16/ipQqbT6R5wFNI=;\n\tb=LWzQnDWnj/c0AwGI4+mnKVy+WVdsy35mY/kjQrfaVkBrymInTNLbQKnOrVYON2eZIt\n\tGZxbJZL9AbOobhLda43FWKYSfnY+OCUSUlEXKi4uokLNLs18PGanUHAagaZ9UZk16G99\n\tggY9yM5OyapKrw48fAiK7lEzhRSFizEA3BHEdCWvqEDL+sJmf04UQHaLEgJhmAgdl0sY\n\tErXhsuwSTvYTKZ4bGJsCVE0QC7Qku1ATrrINsCqiWJxZRQLhBq2nh99qoS9iegA7qN05\n\tZdt+h7YkjISTqsg67RQ5iRg7fv0DxgBKFp+qcMZ8Q0fkeRJKZVIqmq4b9PgSKE9yKOM0\n\t9QwA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=XhhUci6NIj8QjiiV9JcEPodspuV16/ipQqbT6R5wFNI=;\n\tb=EwS/98RPyXvpjnXAlR953UrDb2Hc5AORkBSIUkwOU76Q48jXtjUPkFJQdYIailfzAh\n\tsNGJcas2Xk6eTR6YsDgkXcFqvMlgk85I9G6gE7wj5xpuAu9jE0ZG7ysnMltr1PihDh3e\n\trly3XeknV1hAww5QHFI2df399XqW9MjbJbudybqVOufoRi6L3ginF5Zu6A3aQJcVN6aN\n\tJxCWA1+Et3/Rrc+iearA/fDVzqqskDDowcg4C/VVMVFit2dui6aBpuLW2i6duv325Pv9\n\tY17DROFI2MZKKhv2qqDzH6Au1DXOpaBm0X5y4mblAA4tMvVBFdTN5MosC4S13iREgWkM\n\t/tkQ==","X-Gm-Message-State":"APjAAAWp2iuXcmIoHUpch7TipmZ9Z/cEbSRRk7KdiaFu4etfCiLyrTrO\n\tInmS/L1qn3D9bd4FKpPv/O4AL/kPH0E=","X-Google-Smtp-Source":"APXvYqxtJE0G89kbMQUIR0bRqMLGOAExRcg2GHf6BJDL9gPYYL+zcJiqGPccsofUVpUukXJYn8EVog==","X-Received":"by 2002:a2e:8316:: with SMTP id\n\ta22mr5022216ljh.171.1555455542641; \n\tTue, 16 Apr 2019 15:59:02 -0700 (PDT)","Date":"Wed, 17 Apr 2019 00:59:01 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190416225901.GH28515@bigcity.dyn.berto.se>","References":"<20190416220839.1577-1-laurent.pinchart@ideasonboard.com>\n\t<20190416220839.1577-9-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190416220839.1577-9-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v2 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":"Tue, 16 Apr 2019 22:59:03 -0000"}},{"id":1425,"web_url":"https://patchwork.libcamera.org/comment/1425/","msgid":"<20190417080240.mf4zdcc5xkdbalom@uno.localdomain>","date":"2019-04-17T08:02:40","subject":"Re: [libcamera-devel] [PATCH v2 08/13] libcamera: utils: Add\n\tset_overlap() function","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Apr 17, 2019 at 01:08:34AM +0300, Laurent Pinchart wrote:\n> The new set_overlap() function counts the number of overlapping elements\n> in the intersection of two sorted ranges defined by their beginning and\n> ending iterators.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nVery nice indeed! Thanks\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n> ---\n>  src/libcamera/include/utils.h | 19 +++++++++++++++++++\n>  src/libcamera/utils.cpp       | 12 ++++++++++++\n>  2 files changed, 31 insertions(+)\n>\n> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> index 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 */\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 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> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4634E60DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 10:01:49 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id B5DB5FF80A;\n\tWed, 17 Apr 2019 08:01:48 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 17 Apr 2019 10:02:40 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190417080240.mf4zdcc5xkdbalom@uno.localdomain>","References":"<20190416220839.1577-1-laurent.pinchart@ideasonboard.com>\n\t<20190416220839.1577-9-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"q4l5huiveow6pnjl\"","Content-Disposition":"inline","In-Reply-To":"<20190416220839.1577-9-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 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":"Wed, 17 Apr 2019 08:01:49 -0000"}}]