casacore
Loading...
Searching...
No Matches
StdLogical.h
Go to the documentation of this file.
1// # StdLogical.h: Logical Operations on STL-style containers
2// # Copyright (C) 2012
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_STDLOGICAL_H
27#define CASA_STDLOGICAL_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/BasicMath/Functors.h>
31
32namespace casacore {
33
34// Arbitrary compare operation on two STL-style containers.
35// It returns True if containers have equal size and
36// all elements compare True.
37template <typename C1, typename C2, typename CompareOperator>
38bool compareAll(const C1& l, const C2& r, CompareOperator op) {
39 if (l.size() != r.size()) return false;
40 return compareAll(l.begin(), l.end(), r.begin(), op);
41}
42
43// Test if all elements of the containers are relatively near each other.
44template <typename C1, typename C2, typename U>
45bool allNear(const C1& l, const C2& r, U tolerance) {
46 return compareAll(l, r, Near<U>(tolerance));
47}
48
49// Test if all elements of the containers are absolutely near each other.
50template <typename C1, typename C2, typename U>
51bool allNearAbs(const C1& l, const C2& r, U tolerance) {
52 return compareAll(l, r, NearAbs<U>(tolerance));
53}
54
55} // namespace casacore
56
57// # #ifndef CASACORE_NO_AUTO_TEMPLATES
58// # #include <casacore/casa/BasicMath/StdLogical.tcc>
59// # #endif //# CASACORE_NO_AUTO_TEMPLATES
60
61#endif
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool compareAll(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition Functors.h:87
bool allNearAbs(const C1 &l, const C2 &r, U tolerance)
Test if all elements of the containers are absolutely near each other.
Definition StdLogical.h:51
bool allNear(const C1 &l, const C2 &r, U tolerance)
Test if all elements of the containers are relatively near each other.
Definition StdLogical.h:45
Functor to test for if two values are absolutely near each other.
Definition Functors.h:261
Functor to test if two values are relatively near each other.
Definition Functors.h:251