casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 
29 #ifndef CASA_STDLOGICAL_H
30 #define CASA_STDLOGICAL_H
31 
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore {
36 
37  // Arbitrary compare operation on two STL-style containers.
38  // It returns True if containers have equal size and
39  // all elements compare True.
40  template<typename C1, typename C2, typename CompareOperator>
41  bool compareAll (const C1& l, const C2& r, CompareOperator op)
42  {
43  if (l.size() != r.size()) return false;
44  return compareAll (l.begin(), l.end(), r.begin(), op);
45  }
46 
47  // Test if all elements of the containers are relatively near each other.
48  template<typename C1, typename C2, typename U>
49  bool allNear (const C1& l, const C2& r, U tolerance)
50  { return compareAll (l, r, Near<U>(tolerance)); }
51 
52  // Test if all elements of the containers are absolutely near each other.
53  template<typename C1, typename C2, typename U>
54  bool allNearAbs (const C1& l, const C2& r, U tolerance)
55  { return compareAll (l, r, NearAbs<U>(tolerance)); }
56 
57 
58 } //# end namespace casacore
59 
60 
61 //# #ifndef CASACORE_NO_AUTO_TEMPLATES
62 //# #include <casacore/casa/BasicMath/StdLogical.tcc>
63 //# #endif //# CASACORE_NO_AUTO_TEMPLATES
64 
65 #endif
Functor to test for if two values are absolutely near each other.
Definition: Functors.h:308
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:54
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:49
Functor to test if two values are relatively near each other.
Definition: Functors.h:295
bool compareAll(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:97
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42