aboutsummaryrefslogtreecommitdiffstats
path: root/include/iterator_range.h
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-03-02 02:44:41 +0000
committerGravatar Sadie Powell2021-03-02 02:56:49 +0000
commit3f113fc04628491cb795d2fc809d89ff2379c61a (patch)
tree96f157ee67231916a41bdc4f73b92b96f229a05e /include/iterator_range.h
parentReplace manual copy prevention with the insp::uncopiable class. (diff)
Move iterator_range to the utility directory and renamespace.
Diffstat (limited to 'include/iterator_range.h')
-rw-r--r--include/iterator_range.h80
1 files changed, 0 insertions, 80 deletions
diff --git a/include/iterator_range.h b/include/iterator_range.h
deleted file mode 100644
index e760646d5..000000000
--- a/include/iterator_range.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * InspIRCd -- Internet Relay Chat Daemon
- *
- * Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
- *
- * This file is part of InspIRCd. InspIRCd is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#pragma once
-
-namespace stdalgo
-{
- template <typename Iterator>
- class iterator_range;
-
- /** Returns a range containing all elements equivalent to \p value.
- * @param collection The collection to search within.
- * @param value The value to search for.
- */
- template <typename Collection, typename Value>
- iterator_range<typename Collection::const_iterator> equal_range(const Collection& collection, const Value& value)
- {
- return collection.equal_range(value);
- }
-}
-
-/** Represents a range of iterators. */
-template <typename Iterator>
-class stdalgo::iterator_range
-{
- private:
- /** An iterator which points to the start of the range. */
- const Iterator begini;
-
- /* An iterator which points to one past the end of the range. */
- const Iterator endi;
-
- public:
- /** Initialises a new iterator range with the specified iterators.
- * @param begin An iterator which points to the start of the range.
- * @param end An iterator which points to one past the end of the range.
- */
- iterator_range(Iterator begin, Iterator end)
- : begini(begin)
- , endi(end)
- {
- }
-
- /** Initialises a new iterator range from a pair of iterators.
- * @param range A pair of iterators in the format [first, last).
- */
- iterator_range(std::pair<Iterator, Iterator> range)
- : begini(range.first)
- , endi(range.second)
- {
- }
-
- /** Determines whether the iterator range is empty. */
- bool empty() const { return begini == endi; }
-
- /** Retrieves an iterator which points to the start of the range. */
- const Iterator& begin() const { return begini; }
-
- /** Retrieves an iterator which points to one past the end of the range. */
- const Iterator& end() const { return endi; }
-
- /** Retrieves the number of hops within the iterator range. */
- typename Iterator::difference_type count() const { return std::distance(begini, endi); }
-};