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-04-09 17:58:58 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.4 1998/03/14 00:04:47 tveldhui
|
---|
27 | * 0.2-alpha-05
|
---|
28 | *
|
---|
29 | * Revision 1.3 1997/07/16 14:51:20 tveldhui
|
---|
30 | * Update: Alpha release 0.2 (Arrays)
|
---|
31 | *
|
---|
32 | * Revision 1.2 1997/01/24 14:42:00 tveldhui
|
---|
33 | * Periodic RCS update
|
---|
34 | *
|
---|
35 | * Revision 1.1 1997/01/13 22:19:58 tveldhui
|
---|
36 | * Periodic RCS update
|
---|
37 | *
|
---|
38 | *
|
---|
39 | */
|
---|
40 |
|
---|
41 | #ifndef BZ_EXTREMUM_H
|
---|
42 | #define BZ_EXTREMUM_H
|
---|
43 |
|
---|
44 | #ifndef BZ_BLITZ_H
|
---|
45 | #include <blitz/blitz.h>
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | BZ_NAMESPACE(blitz)
|
---|
49 |
|
---|
50 | // The Extremum class is used for returning extreme values and their
|
---|
51 | // locations in a numeric container. It's a simple 2-tuple, with the
|
---|
52 | // first element being the extreme value, and the send its location.
|
---|
53 | // An object of type Extremum can be automatically converted to
|
---|
54 | // the numeric type via operator T_numtype().
|
---|
55 | template<class P_numtype, class P_index>
|
---|
56 | class Extremum {
|
---|
57 | public:
|
---|
58 | typedef P_numtype T_numtype;
|
---|
59 | typedef P_index T_index;
|
---|
60 |
|
---|
61 | Extremum(T_numtype value, T_index index)
|
---|
62 | : value_(value), index_(index)
|
---|
63 | { }
|
---|
64 |
|
---|
65 | T_numtype value() const
|
---|
66 | { return value_; }
|
---|
67 |
|
---|
68 | T_index index() const
|
---|
69 | { return index_; }
|
---|
70 |
|
---|
71 | void setValue(T_numtype value)
|
---|
72 | { value_ = value; }
|
---|
73 |
|
---|
74 | void setIndex(T_index index)
|
---|
75 | { index_ = index; }
|
---|
76 |
|
---|
77 | operator T_numtype() const
|
---|
78 | { return value_; }
|
---|
79 |
|
---|
80 | protected:
|
---|
81 | T_numtype value_;
|
---|
82 | T_index index_;
|
---|
83 | };
|
---|
84 |
|
---|
85 | BZ_NAMESPACE_END
|
---|
86 |
|
---|
87 | #endif // BZ_EXTREMUM_H
|
---|
88 |
|
---|