blitz Version 0.10
blitz/extremum.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  * blitz/extremum.h      Declaration of the Extremum<T_numtype, T_index> class
00004  *
00005  * $Id: extremum.h,v 1.5 2011/03/25 22:41:16 julianc Exp $
00006  *
00007  * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
00008  *
00009  * This file is a part of Blitz.
00010  *
00011  * Blitz is free software: you can redistribute it and/or modify 
00012  * it under the terms of the GNU Lesser General Public License
00013  * as published by the Free Software Foundation, either version 3
00014  * of the License, or (at your option) any later version.
00015  *
00016  * Blitz is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public 
00022  * License along with Blitz.  If not, see <http://www.gnu.org/licenses/>.
00023  * 
00024  * Suggestions:          blitz-devel@lists.sourceforge.net
00025  * Bugs:                 blitz-support@lists.sourceforge.net    
00026  *
00027  * For more information, please see the Blitz++ Home Page:
00028  *    https://sourceforge.net/projects/blitz/
00029  *
00030  ***************************************************************************/
00031 
00032 #ifndef BZ_EXTREMUM_H
00033 #define BZ_EXTREMUM_H
00034 
00035 #ifndef BZ_BLITZ_H
00036  #include <blitz/blitz.h>
00037 #endif
00038 
00039 BZ_NAMESPACE(blitz)
00040 
00041 // The Extremum class is used for returning extreme values and their
00042 // locations in a numeric container.  It's a simple 2-tuple, with the
00043 // first element being the extreme value, and the send its location.
00044 // An object of type Extremum can be automatically converted to
00045 // the numeric type via operator T_numtype().
00046 template<typename P_numtype, typename P_index>
00047 class Extremum {
00048 public:
00049     typedef P_numtype T_numtype;
00050     typedef P_index   T_index;
00051 
00052     Extremum(T_numtype value, T_index index)
00053         : value_(value), index_(index)
00054     { }
00055 
00056     T_numtype value() const
00057     { return value_; }
00058 
00059     T_index index() const
00060     { return index_; }
00061 
00062     void setValue(T_numtype value)
00063     { value_ = value; }
00064 
00065     void setIndex(T_index index)
00066     { index_ = index; }
00067 
00068     operator T_numtype() const
00069     { return value_; }
00070 
00071 protected:
00072     T_numtype value_;
00073     T_index index_;
00074 };
00075 
00076 BZ_NAMESPACE_END
00077 
00078 #endif // BZ_EXTREMUM_H
00079 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines