📄 int.hpp
字号:
/* * Open BEAGLE * Copyright (C) 2001-2005 by Christian Gagne and Marc Parizeau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact: * Laboratoire de Vision et Systemes Numeriques * Departement de genie electrique et de genie informatique * Universite Laval, Quebec, Canada, G1K 7P4 * http://vision.gel.ulaval.ca * *//*! * \file beagle/Int.hpp * \brief Definition of the type Int and related operators. * \author Christian Gagne * \author Marc Parizeau * $Revision: 1.7 $ * $Date: 2005/09/30 15:04:54 $ */#ifndef Beagle_Int_hpp#define Beagle_Int_hpp#include "beagle/config.hpp"#include "beagle/macros.hpp"#include "beagle/WrapperT.hpp"#include "beagle/ArrayT.hpp"namespace Beagle {/*! * \brief Beagle wrapper of the atomic int type. * \ingroup Adapt */typedef WrapperT< int > Int;/*! * \brief Beagle array of the atomic int type. * \ingroup Adapt */typedef ArrayT< int > IntArray;/*! * \brief Evaluate absolute value of a Beagle::Int. * \param inValue Int to evaluate the absolute value. * \return Absolute value of the input. * \ingroup Adapt */template <>inline Int absolute(const Int& inValue){ Beagle_StackTraceBeginM(); return Int(std::abs(inValue.getWrappedValue())); Beagle_StackTraceEndM("Int absolute(const Int& inValue)");}}/*! * \brief Test whether an int is less than another. * \param inLeftInt Left int compared. * \param inRightInt Right int compared. * \return True if left int is less than the right one, false if not. * \par Note: * The operator is defined relatively to the function isLess of Beagle::Int. */inline bool operator<(const Beagle::Int& inLeftInt, const Beagle::Int& inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.isLess(inRightInt); Beagle_StackTraceEndM("bool operator<(const Int& inLeftInt, const Int& inRightInt)");}/*! * \brief Test whether an int is less than, or equal to another. * \param inLeftInt Left int compared. * \param inRightInt Right int compared. * \return True if left int is less than, or equal to the right one, false if not. * \par Note: * The operator is defined relatively to the functions isLess and isEqual of Beagle::Int. */inline bool operator<=(const Beagle::Int& inLeftInt, const Beagle::Int& inRightInt){ Beagle_StackTraceBeginM(); return ( inLeftInt.isLess(inRightInt) || inLeftInt.isEqual(inRightInt) ); Beagle_StackTraceEndM("bool operator<=(const Int& inLeftInt, const Int& inRightInt)");}/*! * \brief Test whether an int is more than another. * \param inLeftInt Left int compared. * \param inRightInt Right int compared. * \return True if left int is more than the right one, false if not. * \par Note: * The operator is defined relatively to the function isLess of Beagle::Int. */inline bool operator>(const Beagle::Int& inLeftInt, const Beagle::Int& inRightInt){ Beagle_StackTraceBeginM(); return inRightInt.isLess(inLeftInt); Beagle_StackTraceEndM("bool operator>(const Int& inLeftInt, const Int& inRightInt)");}/*! * \brief Test whether an int is more than, or equal to another. * \param inLeftInt Left int compared. * \param inRightInt Right int compared. * \return True if left int is more than, or equal to the right one, false if not. * \par Note: * The operator is defined relatively to the functions isLess and isEqual of Beagle::Int. */inline bool operator>=(const Beagle::Int& inLeftInt, const Beagle::Int& inRightInt){ Beagle_StackTraceBeginM(); return ( inRightInt.isLess(inLeftInt) || inLeftInt.isEqual(inRightInt) ); Beagle_StackTraceEndM("bool operator>=(const Int& inLeftInt, const Int& inRightInt)");}/*! * \brief Test whether an int is equal to another. * \param inLeftInt Left int compared. * \param inRightInt Right int compared. * \return True if left int is equal to the right one, false if not. * \par Note: * The operator is defined relatively to the function isEqual of Beagle::Int. */inline bool operator==(const Beagle::Int& inLeftInt, const Beagle::Int& inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.isEqual(inRightInt); Beagle_StackTraceEndM("bool operator==(const Int& inLeftInt, const Int& inRightInt)");}/*! * \brief Test whether an int is not equal to another. * \param inLeftInt Left int compared. * \param inRightInt Right int compared. * \return True if left int is not equal to the right one, false if it is. * \par Note: * The operator is defined relatively to the function isEqual of Beagle::Int. */inline bool operator!=(const Beagle::Int& inLeftInt, const Beagle::Int& inRightInt){ Beagle_StackTraceBeginM(); return ( inLeftInt.isEqual(inRightInt) == false); Beagle_StackTraceEndM("bool operator!=(const Int& inLeftInt, const Int& inRightInt)");}/*! * \brief Compare equality of a Int with a int. * \param inLeftInt Left value to compare. * \param inRightInt Right value to compare. * \return Result of the comparison. */inlinebool operator==(const Beagle::Int& inLeftInt, int inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.getWrappedValue() == inRightInt; Beagle_StackTraceEndM("bool operator==(const Int& inLeftInt, int inRightInt)");}/*! * \brief Compare inequality of a Int with a int. * \param inLeftInt Left value to compare. * \param inRightInt Right value to compare. * \return Result of the comparison. */inlinebool operator!=(const Beagle::Int& inLeftInt, int inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.getWrappedValue() != inRightInt; Beagle_StackTraceEndM("bool operator!=(const Int& inLeftInt, int inRightInt)");}/*! * \brief Test if a Int is < than a int. * \param inLeftInt Left value to compare. * \param inRightInt Right value to compare. * \return Result of the comparison. */inlinebool operator<(const Beagle::Int& inLeftInt, int inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.getWrappedValue() < inRightInt; Beagle_StackTraceEndM("bool operator<(const Int& inLeftInt, int inRightInt)");}/*! * \brief Test if a Int is <= than a int. * \param inLeftInt Left value to compare. * \param inRightInt Right value to compare. * \return Result of the comparison. */inlinebool operator<=(const Beagle::Int& inLeftInt, int inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.getWrappedValue() <= inRightInt; Beagle_StackTraceEndM("bool operator<=(const Int& inLeftInt, int inRightInt)");}/*! * \brief Test if a Int is > than a int. * \param inLeftInt Left value to compare. * \param inRightInt Right value to compare. * \return Result of the comparison. */inlinebool operator>(const Beagle::Int& inLeftInt, int inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.getWrappedValue() > inRightInt; Beagle_StackTraceEndM("bool operator>(const Int& inLeftInt, int inRightInt)");}/*! * \brief Test if a Int is >= than a int. * \param inLeftInt Left value to compare. * \param inRightInt Right value to compare. * \return Result of the comparison. */inlinebool operator>=(const Beagle::Int& inLeftInt, int inRightInt){ Beagle_StackTraceBeginM(); return inLeftInt.getWrappedValue() >= inRightInt; Beagle_StackTraceEndM("bool operator>=(const Int& inLeftInt, int inRightInt)");}/*! * \brief Increment a Int (prefix version). * \param inInt Int to increment. * \return Int incremented. */inlineBeagle::Int& operator++(Beagle::Int& inInt){ Beagle_StackTraceBeginM(); inInt.getWrappedValue()++; return inInt; Beagle_StackTraceEndM("Int& operator++(Int& inInt)");}/*! * \brief Increment a Int (postfix version). * \param inInt Int to increment. * \return Int before being incremented. */inlineBeagle::Int operator++(Beagle::Int& inInt, int){ Beagle_StackTraceBeginM(); Beagle::Int lInt = inInt; inInt.getWrappedValue()++; return lInt;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -