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 
18 namespace isc {
19 namespace util {
20 
27 template <typename Iterator>
28 bool
29 isRangeZero(Iterator begin, Iterator end) {
30  return (std::find_if(begin, end,
31  std::bind1st(std::not_equal_to<int>(), 0))
32  == end);
33 }
34 
51 template <typename Iterator>
52 void
53 fillRandom(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
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::util::fillRandom
void fillRandom(Iterator begin, Iterator end)
Fill in specified range with a random data.
Definition: range_utilities.h:53
isc::util::isRangeZero
bool isRangeZero(Iterator begin, Iterator end)
Checks if specified range in a container contains only zeros.
Definition: range_utilities.h:29