| [658] | 1 | /*************************************************************************** | 
|---|
|  | 2 | * blitz/extremum.h      Declaration of the Extremum<T_numtype, T_index> class | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * $Id: extremum.h,v 1.1.1.1 1999-11-26 16:37:03 ansari Exp $ | 
|---|
|  | 5 | * | 
|---|
|  | 6 | * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca> | 
|---|
|  | 7 | * | 
|---|
|  | 8 | * This program is free software; you can redistribute it and/or | 
|---|
|  | 9 | * modify it under the terms of the GNU General Public License | 
|---|
|  | 10 | * as published by the Free Software Foundation; either version 2 | 
|---|
|  | 11 | * of the License, or (at your option) any later version. | 
|---|
|  | 12 | * | 
|---|
|  | 13 | * This program is distributed in the hope that it will be useful, | 
|---|
|  | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 16 | * GNU General Public License for more details. | 
|---|
|  | 17 | * | 
|---|
|  | 18 | * Suggestions:          blitz-suggest@cybervision.com | 
|---|
|  | 19 | * Bugs:                 blitz-bugs@cybervision.com | 
|---|
|  | 20 | * | 
|---|
|  | 21 | * For more information, please see the Blitz++ Home Page: | 
|---|
|  | 22 | *    http://seurat.uwaterloo.ca/blitz/ | 
|---|
|  | 23 | * | 
|---|
|  | 24 | *************************************************************************** | 
|---|
|  | 25 | * $Log: not supported by cvs2svn $ | 
|---|
|  | 26 | * Revision 1.1.1.1  1999/04/09  17:58:58  ansari | 
|---|
|  | 27 | * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99 | 
|---|
|  | 28 | * | 
|---|
|  | 29 | * Revision 1.4  1998/03/14 00:04:47  tveldhui | 
|---|
|  | 30 | * 0.2-alpha-05 | 
|---|
|  | 31 | * | 
|---|
|  | 32 | * Revision 1.3  1997/07/16 14:51:20  tveldhui | 
|---|
|  | 33 | * Update: Alpha release 0.2 (Arrays) | 
|---|
|  | 34 | * | 
|---|
|  | 35 | * Revision 1.2  1997/01/24 14:42:00  tveldhui | 
|---|
|  | 36 | * Periodic RCS update | 
|---|
|  | 37 | * | 
|---|
|  | 38 | * Revision 1.1  1997/01/13 22:19:58  tveldhui | 
|---|
|  | 39 | * Periodic RCS update | 
|---|
|  | 40 | * | 
|---|
|  | 41 | * | 
|---|
|  | 42 | */ | 
|---|
|  | 43 |  | 
|---|
|  | 44 | #ifndef BZ_EXTREMUM_H | 
|---|
|  | 45 | #define BZ_EXTREMUM_H | 
|---|
|  | 46 |  | 
|---|
|  | 47 | #ifndef BZ_BLITZ_H | 
|---|
|  | 48 | #include <blitz/blitz.h> | 
|---|
|  | 49 | #endif | 
|---|
|  | 50 |  | 
|---|
|  | 51 | BZ_NAMESPACE(blitz) | 
|---|
|  | 52 |  | 
|---|
|  | 53 | // The Extremum class is used for returning extreme values and their | 
|---|
|  | 54 | // locations in a numeric container.  It's a simple 2-tuple, with the | 
|---|
|  | 55 | // first element being the extreme value, and the send its location. | 
|---|
|  | 56 | // An object of type Extremum can be automatically converted to | 
|---|
|  | 57 | // the numeric type via operator T_numtype(). | 
|---|
|  | 58 | template<class P_numtype, class P_index> | 
|---|
|  | 59 | class Extremum { | 
|---|
|  | 60 | public: | 
|---|
|  | 61 | typedef P_numtype T_numtype; | 
|---|
|  | 62 | typedef P_index   T_index; | 
|---|
|  | 63 |  | 
|---|
|  | 64 | Extremum(T_numtype value, T_index index) | 
|---|
|  | 65 | : value_(value), index_(index) | 
|---|
|  | 66 | { } | 
|---|
|  | 67 |  | 
|---|
|  | 68 | T_numtype value() const | 
|---|
|  | 69 | { return value_; } | 
|---|
|  | 70 |  | 
|---|
|  | 71 | T_index index() const | 
|---|
|  | 72 | { return index_; } | 
|---|
|  | 73 |  | 
|---|
|  | 74 | void setValue(T_numtype value) | 
|---|
|  | 75 | { value_ = value; } | 
|---|
|  | 76 |  | 
|---|
|  | 77 | void setIndex(T_index index) | 
|---|
|  | 78 | { index_ = index; } | 
|---|
|  | 79 |  | 
|---|
|  | 80 | operator T_numtype() const | 
|---|
|  | 81 | { return value_; } | 
|---|
|  | 82 |  | 
|---|
|  | 83 | protected: | 
|---|
|  | 84 | T_numtype value_; | 
|---|
|  | 85 | T_index index_; | 
|---|
|  | 86 | }; | 
|---|
|  | 87 |  | 
|---|
|  | 88 | BZ_NAMESPACE_END | 
|---|
|  | 89 |  | 
|---|
|  | 90 | #endif // BZ_EXTREMUM_H | 
|---|
|  | 91 |  | 
|---|