Kea 2.5.8
range_utilities.h
Go to the documentation of this file.
1// Copyright (C) 2012-2019,2021 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, [] (int x) { return (0 != x); })
31 == end);
32}
33
50template <typename Iterator>
51void
52fillRandom(Iterator begin, Iterator end) {
53 for (Iterator x = begin; x != end; ++x) {
54 *x = random();
55 }
56}
57
58} // end of isc::util namespace
59} // end of isc namespace
60
61#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-lfc.