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
27#ifndef CASA_STDLOGICAL_H
28#define CASA_STDLOGICAL_H
29
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicMath/Functors.h>
32
33namespace casacore {
34
35 // Arbitrary compare operation on two STL-style containers.
36 // It returns True if containers have equal size and
37 // all elements compare True.
38 template<typename C1, typename C2, typename CompareOperator>
39 bool compareAll (const C1& l, const C2& r, CompareOperator op)
40 {
41 if (l.size() != r.size()) return false;
42 return compareAll (l.begin(), l.end(), r.begin(), op);
43 }
44
45 // Test if all elements of the containers are relatively near each other.
46 template<typename C1, typename C2, typename U>
47 bool allNear (const C1& l, const C2& r, U tolerance)
48 { return compareAll (l, r, Near<U>(tolerance)); }
49
50 // Test if all elements of the containers are absolutely near each other.
51 template<typename C1, typename C2, typename U>
52 bool allNearAbs (const C1& l, const C2& r, U tolerance)
53 { return compareAll (l, r, NearAbs<U>(tolerance)); }
54
55
56} //# end namespace casacore
57
58
59//# #ifndef CASACORE_NO_AUTO_TEMPLATES
60//# #include <casacore/casa/BasicMath/StdLogical.tcc>
61//# #endif //# CASACORE_NO_AUTO_TEMPLATES
62
63#endif
this file contains all the compiler specific defines
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:95
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:52
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:47
Functor to test for if two values are absolutely near each other.
Definition Functors.h:307
Functor to test if two values are relatively near each other.
Definition Functors.h:294