Kea 1.5.0
range_utilities.h
Go to the documentation of this file.
1// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef RANGE_UTIL_H
8#define RANGE_UTIL_H 1
9
10#include <stdlib.h>
11#include <algorithm>
12#include <functional>
13
14// This header contains useful methods for conduction operations on
15// a range of container elements. Currently the collection is limited,
16// but it is expected to grow.
17
18namespace isc {
19namespace util {
20
27template <typename Iterator>
28bool
29isRangeZero(Iterator begin, Iterator end) {
30 return (std::find_if(begin, end,
31 std::bind1st(std::not_equal_to<int>(), 0))
32 == end);
33}
34
51template <typename Iterator>
52void
53fillRandom(Iterator begin, Iterator end) {
54 for (Iterator x = begin; x != end; ++x) {
55 *x = random();
56 }
57}
58
59} // end of isc::util namespace
60} // end of isc namespace
61
62#endif // RANGE_UTIL_H
void fillRandom(Iterator begin, Iterator end)
Fill in specified range with a random data.
bool isRangeZero(Iterator begin, Iterator end)
Checks if specified range in a container contains only zeros.
Defines the logger used by the top-level component of kea-dhcp-ddns.