blitz/extremum.h

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

Generated on Wed Oct 17 15:15:51 2007 for blitz by  doxygen 1.5.2